Size of Icon
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Size of Icon

  1. #1
    Join Date
    Nov 1999
    Location
    Dresden / Germoney
    Posts
    1,402

    Size of Icon

    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


  2. #2
    Join Date
    May 2000
    Location
    Toronto, ON, Canada
    Posts
    3,573

    Re: Size of Icon

    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.
    Regards,

    Emanuel Vaduva

  3. #3
    igbrus is offline Elite Member Power Poster
    Join Date
    Aug 2000
    Location
    Los Angeles
    Posts
    4,658

    Re: Size of Icon

    Try GetIconInfo and GetDIBits after that

    Rating isn't important...But gurus respect it and keep high

  4. #4
    Join Date
    Nov 1999
    Location
    Dresden / Germoney
    Posts
    1,402

    Re: Size of Icon

    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


  5. #5
    Join Date
    May 2000
    Location
    Toronto, ON, Canada
    Posts
    3,573

    Re: Size of Icon

    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.
    Regards,

    Emanuel Vaduva

  6. #6
    Join Date
    May 1999
    Location
    Toulouse, France
    Posts
    171

    Re: Size of Icon

    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.

    We're talking ****, 'cause life is a 'biz
    You know it is
    Everybody tryin' to get rich
    God ****!
    All I wanna do is live !

    KoRn, Children of the Korn

  7. #7
    Join Date
    Nov 1999
    Location
    Dresden / Germoney
    Posts
    1,402

    Re: Size of Icon

    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




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center