use Icon from Windows DLL Resource

Post Reply
User avatar
Jimmy
Posts: 1734
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

use Icon from Windows DLL Resource

Post by Jimmy »

hi,

i have this under Xbase++

Code: Select all | Expand

   ::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
Marc Venken
Posts: 1482
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: use Icon from Windows DLL Resource

Post by Marc Venken »

Marc Venken
Using: FWH 23.08 with Harbour
User avatar
Jimmy
Posts: 1734
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: use Icon from Windows DLL Resource

Post by Jimmy »

hi Marc,

thx for Answer


i have to post my Xbase++ "Load"

Code: Select all | Expand

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

   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
karinha
Posts: 7910
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: use Icon from Windows DLL Resource

Post by karinha »

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
Jimmy
Posts: 1734
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: use Icon from Windows DLL Resource

Post by Jimmy »

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: 1734
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: use Icon from Windows DLL Resource

Post by Jimmy »

hi,

got it :D

Code: Select all | Expand

   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: 1734
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: use Icon from Windows DLL Resource

Post by Jimmy »

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

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

         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: 1734
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: use Icon from Windows DLL Resource

Post by Jimmy »

hi,

got it :D

instead of

Code: Select all | Expand

1342            hdItem.hbm = (HBITMAP) hb_parni(4) ;
i have to use

Code: Select all | Expand

1342            hdItem.hbm = (HBITMAP) hb_parnll(4) ;
Question : is it "safe" use use hb_parnll under 32 Bit :?:
greeting,
Jimmy
Post Reply