static BOOL get_icon_size( HICON handle, SIZE *size )
{
ICONINFO info;
BITMAP bmp;
int ret;
if (!GetIconInfo(handle, &info))
return FALSE;
- ret = GetObjectW(info.hbmColor, sizeof(bmp), &bmp);
+ 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 == 0)
+ size->cy = (size->cy >> 1);
}
DeleteObject(info.hbmMask);
DeleteObject(info.hbmColor);
return !!ret;
}