Here is a way to extract an icon from a resource file (dll/exe) at the size you desire and use it with an image gadget (the function returns an icon handle so an imageID in PB) :
Code: Select all
; Macro LOWORD(dwValue) : dwValue & $FFFF : EndMacro
; Macro HIWORD(dwValue) : dwValue >> 16 : EndMacro
Prototype.i Proto_SHDefExtractIcon(pszIconFile.s, iIndex.i, uFlags.i, phiconLarge.i, phiconSmall.i, nIconSize.i)
Procedure ExtractArbitrarySizeIcon(pszPath.s, index, size)
Protected hIcon
OpenLibrary(0, "Shell32.dll")
Protected SHDefExtractIcon_.Proto_SHDefExtractIcon = GetFunction(0, "SHDefExtractIconW")
If SHDefExtractIcon_(pszPath, index, 0, @hIcon, #Null, size) = #S_OK
ProcedureReturn hIcon
EndIf
ProcedureReturn 0
EndProcedure
If OpenWindow(0, 0, 0, 300, 50, "ImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
hicon1 = ExtractArbitrarySizeIcon("c:\windows\system32\shell32.dll", 22, 16)
ImageGadget(1, 0, 0, 50, 50, hicon1)
hicon2 = ExtractArbitrarySizeIcon("c:\windows\system32\shell32.dll", 22, 24)
ImageGadget(2, 50, 0, 50, 50, hicon2)
hicon3 = ExtractArbitrarySizeIcon("c:\windows\system32\shell32.dll", 22, 32)
ImageGadget(3, 100, 0, 50, 50, hicon3)
hicon4 = ExtractArbitrarySizeIcon("c:\windows\system32\shell32.dll", 22, 40)
ImageGadget(4, 150, 0, 50, 50, hicon4)
hicon5 = ExtractArbitrarySizeIcon("c:\windows\system32\shell32.dll", 22, 48)
ImageGadget(5, 200, 0, 50, 50, hicon5)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
DestroyIcon_(hicon1)
DestroyIcon_(hicon2)
DestroyIcon_(hicon3)
DestroyIcon_(hicon4)
DestroyIcon_(hicon5)
The doc doesn't match my experience. It seems you can use only the phiconLarge pointer to get every size you want...