Hi all!
How to get the size of an Icon? I just have a HICON, and need it's dimensions.
Any help? (Rating guranteed ;-)
Peter
Printable View
Hi all!
How to get the size of an Icon? I just have a HICON, and need it's dimensions.
Any help? (Rating guranteed ;-)
Peter
Hi,
Maybe this will help youICONINFO icoInfo;
BITMAP bmpInfo;
GetIconInfo(hIcon, &icoInfo);
CBitmap::FromHandle(icoInfo.hbmMask)->GetBitmap(&bmpInfo);
Tell me if that help.
Regards,
Emi.
Try GetIconInfo and GetDIBits after that
Rating isn't important...But gurus respect it and keep high
Thanks!
I already thought of that - but I was looking for a better way. As much as I understand the documentation, the bitmaps are copies of the icon, I'd like to avoid that...
Peter
You are welcome.
Maybe you checked in MSDN at: "Reading and Writing Icons from ExtractIcon". If not see that, maybe it could help you.
Regards,
Emi.
IMHO, the main problem is the size of an icon doesn't mean anything. For example, an icon may contain several bitmaps (4 max., if I remember well), each bitmap may have a different size. So what is the size of an icon in this case ?
Another example: an icon may have only one bitmap, 16 x 16 pixels, but there's no problem to display this icon in 32x32...
So the only information about the size is the "primary" size(s) of the contained bitmap(s), which you can get with the previously described method.
HTH?
K.
Hi,
Yes, Icon *Resources* can be in multiple sizes & color depths, but when loaded and as a HICON, it has a definite size & depth (a MSDN suggests it's internally represented as some DDB's).
I get the HICON from caller, and the actual size to position it correctly. And I thought the GetIconInfo (which extracts copies of the DDB's) is a bit of a kludge. but it seems it's the only way by now.
Peter