FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour use Icon from Windows DLL Resource
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

use Icon from Windows DLL Resource

Posted: Tue Feb 14, 2023 06:32 AM
hi,

i have this under Xbase++
Code (fw): Select all Collapse
   ::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
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM

Re: use Icon from Windows DLL Resource

Posted: Tue Feb 14, 2023 08:14 AM
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

Re: use Icon from Windows DLL Resource

Posted: Tue Feb 14, 2023 10:05 AM
hi Marc,

thx for Answer


i have to post my Xbase++ "Load"
Code (fw): Select all Collapse
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 (fw): Select all Collapse
   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
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

Re: use Icon from Windows DLL Resource

Posted: Tue Feb 14, 2023 03: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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

Re: use Icon from Windows DLL Resource

Posted: 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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

Re: use Icon from Windows DLL Resource

Posted: Wed Feb 15, 2023 05:05 AM
hi,

got it :D
Code (fw): Select all Collapse
   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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

Re: use Icon from Windows DLL Resource

Posted: 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 (fw): Select all Collapse
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 (fw): Select all Collapse
         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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM

Re: use Icon from Windows DLL Resource

Posted: Fri Feb 17, 2023 05:22 AM
hi,

got it :D

instead of
Code (fw): Select all Collapse
1342            hdItem.hbm = (HBITMAP) hb_parni(4) ;
i have to use
Code (fw): Select all Collapse
1342            hdItem.hbm = (HBITMAP) hb_parnll(4) ;
Question : is it "safe" use use hb_parnll under 32 Bit :?:
greeting,

Jimmy

Continue the discussion