static BOOL get_icon_size( HICON handle, SIZE *size )
{
ICONINFO info;
BITMAP bmp;
int ret;
if (!GetIconInfo(handle, &info))
return FALSE;
ret = GetObjectW(info.hbmMask, sizeof(bmp), &bmp);
if (ret)
{
size->cx = bmp.bmWidth;
size->cy = bmp.bmHeight;
/*
If this structure defines a black and white icon, this bitmask is formatted
so that the upper half is the icon AND bitmask and the lower half is
the icon XOR bitmask.
*/
if (!info.hbmColor)
size->cy /= 2;
}
GetIconInfo() fill info.hbmColor with NULL HBITMAP handle on black/white bitmaps
DeleteObject(info.hbmMask);
DeleteObject(info.hbmColor);
return !!ret;
}