In order to get the modern icons, use LoadIconWithScaleDown_().
Code: Select all
; tested with PB 6.03 LTS (x64) on Windows 11
EnableExplicit
; ------------------------------------------------------------------
; -- Get *modern* system icons;
; Windows Vista or newer required
; <https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-loadiconwithscaledown>
Prototype.i ProtoLoadIconWithScaleDown (hInst.i, *szName, cx.i, cy.i, *hIco)
Global LoadIconWithScaleDown_.ProtoLoadIconWithScaleDown
Define dll.i = OpenLibrary(#PB_Any, "Comctl32.dll")
If dll
LoadIconWithScaleDown_ = GetFunction(dll, "LoadIconWithScaleDown")
CloseLibrary(dll)
EndIf
; ------------------------------------------------------------------
Enumeration
#WinMain
EndEnumeration
Procedure.i ShowSystemIcons (iconSize.i)
Protected.i hImg, hIco
If OpenWindow(#WinMain, 0, 0, 150+iconSize, 4*10+3*iconSize, "Windows system icons", #PB_Window_SystemMenu|#PB_Window_ScreenCentered) = 0
MessageRequester("Error",
"Can't open window.",
#PB_MessageRequester_Error)
ProcedureReturn 0
EndIf
; old fashioned
ImageGadget(#PB_Any, 20, 10, iconSize, iconSize, LoadIcon_(#Null, #IDI_INFORMATION))
; old fashioned
hImg = LoadImage_(#Null, #IDI_INFORMATION, #IMAGE_ICON, iconSize, iconSize, #LR_SHARED)
ImageGadget(#PB_Any, 20, 2*10+iconSize, iconSize, iconSize, hImg)
; modern style
If LoadIconWithScaleDown_ <> 0 And LoadIconWithScaleDown_(#Null, #IDI_INFORMATION, DesktopScaledX(iconSize), DesktopScaledY(iconSize), @hIco) = #S_OK
ImageGadget(#PB_Any, 20, 3*10+2*iconSize, iconSize, iconSize, hIco)
EndIf
ProcedureReturn 1
EndProcedure
ShowSystemIcons(32)
; ShowSystemIcons(64)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow