Page 1 of 1

use Icon from Windows DLL Resource

Posted: Tue Feb 14, 2023 6:32 am
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

Re: use Icon from Windows DLL Resource

Posted: Tue Feb 14, 2023 8:14 am
by Marc Venken

Re: use Icon from Windows DLL Resource

Posted: Tue Feb 14, 2023 10:05 am
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 :?:

Re: use Icon from Windows DLL Resource

Posted: Tue Feb 14, 2023 3:15 pm
by karinha
Maybe, c:\fwh..\samples\LISTVIE1.PRG

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

Regards, saludos.

Re: use Icon from Windows DLL Resource

Posted: Tue Feb 14, 2023 11:38 pm
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 :?:

Re: use Icon from Windows DLL Resource

Posted: Wed Feb 15, 2023 5:05 am
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 ...

Re: use Icon from Windows DLL Resource

Posted: Thu Feb 16, 2023 12:39 am
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

Re: use Icon from Windows DLL Resource

Posted: Fri Feb 17, 2023 5:22 am
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 :?: