use Icon from Windows DLL Resource

use Icon from Windows DLL Resource

Postby Jimmy » Tue Feb 14, 2023 6:32 am

hi,

i have this under Xbase++

Code: Select all  Expand view
  ::IcoUp := DXE_Icon() :new() :create()
   ::IcoUp:load( WinDir+"\System32\NetShell.dll", 2301,16,16 )

   ::IcoDn := DXE_Icon() :new() :create()
   ::IcoDn:load( WinDir+"\System32\NetShell.dll", 2300,16,16 )

these are up/down Arrow for my Listview "Grid" Header

how under Fivewin :?:

---

LOADIMAGEFILEICON() seems for "File"-Icon but i want to use Resource "in" DLL
LOADIMAGERESICON() seems to be a Way and also LOADIMAGEICON() but i can not find a Sample
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: use Icon from Windows DLL Resource

Postby Marc Venken » Tue Feb 14, 2023 8:14 am

Not sure, but look at the sample of Mr. Rao.

viewtopic.php?f=3&t=35111

viewtopic.php?f=3&t=35281
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: use Icon from Windows DLL Resource

Postby Jimmy » Tue Feb 14, 2023 10:05 am

hi Marc,

thx for Answer


i have to post my Xbase++ "Load"
Code: Select all  Expand view
INLINE METHOD Load( cDLL, nId, nWidth, nHeight )
LOCAL hModule

   IF ::Handle != 0
      @user32:DestroyIcon( ::Handle )
   ENDIF

   IF ValType(cDLL) == "C"
      hModule := @KERNEL32:GetModuleHandleA( cDLL )
      IF hModule == 0
         hModule := @KERNEL32:LoadLibraryA( cDLL )
      ENDIF
   ELSE
      hModule := @KERNEL32:GetModuleHandleA( 0 )
   ENDIF

   IF ValType(nWidth) != "N"
      nWidth  := 32
   ENDIF
   IF ValType(nHeight) != "N"
      nHeight := 32
   ENDIF

   ::Handle := @user32:LoadImageA( hModule,;
                           nId            ,;
                           IMAGE_ICON     ,;
                           nWidth         ,;
                           nHeight        ,;
                           LR_DEFAULTCOLOR )
   ::GetIconInfo()

RETURN (::Handle)

general it use LoadImage() and Constant IMAGE_ICON but also hModule

but how to write a HB_FUNC()
Code: Select all  Expand view
  Handle = LoadImage( ( HINSTANCE ) hModule, (INT) nID, IMAGE_ICON, (INT) nWidth, (INT) nHeight, LR_DEFAULTCOLOR ) )

or does Fivewin have already a Function for it :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: use Icon from Windows DLL Resource

Postby karinha » Tue Feb 14, 2023 3:15 pm

Maybe, c:\fwh..\samples\LISTVIE1.PRG

or make a complete example. avoid posting pieces of code.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7826
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: use Icon from Windows DLL Resource

Postby Jimmy » Tue Feb 14, 2023 11:38 pm

hi

thx for Answer

Sample c:\fwh\samples\listvie.prg use Icon_Read() which will get "File"-Icon which most are 1st Resource
i want to get Resource Number 2301 from "WinDir+"\System32\NetShell.DLL"

as TGrid() is a new CLASS you need hole CODE for a Demo Sample which now have about 10000 Lines
it might use Technique which Fivewin have not used before

---

the Idea is to use Windows System Icon which "Look" depend on Windows Version
as the same Resource "Number" exist from Windows 98 until Windows 11 you will always get "right" Icon

i found Sample c:\fwh\samples\testigro.prg using ExtractIcon() but i don´t understand "where" Resource come from

btw. how to "create" a Icon like "1 ICON LOADONCALL MOVEABLE DISCARDABLE" in c:\fwh\samples\testigro.rc :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: use Icon from Windows DLL Resource

Postby Jimmy » Wed Feb 15, 2023 5:05 am

hi,

got it :D

Code: Select all  Expand view
  cDLL   := WinDir + "\System32\NetShell.dll"
   ::hModule := GetModuleHandle( cDLL )
   IF ::hModule == 0
      ::hModule := LoadLibrary( cDLL )
   ENDIF
   hIcon := LOADIMAGERESICON(::hModule, 2301, 16 ) // hModule, ResID, Size

i was sure that Fivewin have a Function ... but i have to find it ...
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: use Icon from Windows DLL Resource

Postby Jimmy » Thu Feb 16, 2023 12:39 am

hi,

i got Warnings under MSVC 64 Bit
HB_FUNC.PRG(1342): warning C4312: "Typumwandlung": Konvertierung von "int" in größeren Typ "HBITMAP"
HB_FUNC.PRG(1344): warning C4312: "Typumwandlung": Konvertierung von "int" in größeren Typ "HBITMAP"


Code: Select all  Expand view
1341         if( nType > 0 )
1342            hdItem.hbm = (HBITMAP) hb_parni(4) ;
1343         else
1344            hdItem.hbm = (HBITMAP) hb_parni(4) ;



before i had this
Code: Select all  Expand view
        if( nType > 0 )
            hdItem.hbm = ( HBITMAP ) LoadImage( ( HINSTANCE ) NULL, TEXT( "ICOUP" )   ,   IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT | LR_DEFAULTCOLOR | LR_LOADMAP3DCOLORS | LR_COPYFROMRESOURCE );
         else
            hdItem.hbm = ( HBITMAP ) LoadImage( ( HINSTANCE ) NULL, TEXT( "ICONDOWN" ),   IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT | LR_DEFAULTCOLOR | LR_LOADMAP3DCOLORS | LR_COPYFROMRESOURCE );

---

i do load now Icon from Windows System-Icon and pass it as Parameter Nr. 4 instead to load own Resource
it does run with MSVC 64 Bit but i want to get rid of Warning

how can help me please
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: use Icon from Windows DLL Resource

Postby Jimmy » Fri Feb 17, 2023 5:22 am

hi,

got it :D

instead of
Code: Select all  Expand view
1342            hdItem.hbm = (HBITMAP) hb_parni(4) ;

i have to use
Code: Select all  Expand view
1342            hdItem.hbm = (HBITMAP) hb_parnll(4) ;


Question : is it "safe" use use hb_parnll under 32 Bit :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 82 guests