After finding Jim’s comment, I finally figured it out - ALMOST:
The long code in GraphicsHelpersWFS.IconHandleToPicture can be replaced with this, and it’ll “just work”, at least in Windows 7:
[code] declare sub GetIconInfo Lib “User32” (hIcon as Integer, iconInfo as Ptr)
declare sub GetObjectA Lib “GDI32” (hBitmap as Ptr, size as Integer, struct as Ptr)
declare function DrawIconEx lib “User32” (hDC as integer,X as int32,Y as int32, hIcon as Integer, wx as Integer, wy as Integer, ani as Integer, brush as Integer, flags as Integer) as Boolean
const DI_MASK = 1
const DI_IMAGE = 2
if iconHandle <> 0 then
dim iconInfo as new MemoryBlock(20)
GetIconInfo (iconHandle, iconInfo)
dim bitmapInfo as new MemoryBlock(24)
GetObjectA (iconInfo.Ptr(12), 24, bitmapInfo)
dim ret as new Picture (bitmapInfo.Long(4), bitmapInfo.Long(8), 32)
call DrawIconEx (ret.Graphics.Handle(Graphics.HandleTypeHDC), 0, 0, iconHandle, ret.Width, ret.Height, 0, 0, DI_IMAGE)
call DrawIconEx (ret.Mask.Graphics.Handle(Graphics.HandleTypeHDC), 0, 0, iconHandle, ret.Width, ret.Height, 0, 0, DI_MASK)
return ret
end if[/code]
However: It doesn’t work right in Windows 10! The problem there is that the icon mask is never correct - the mask always is completely black.
Any idea why the icon mask would be right in Win 7 but not in Win 10?