HICON to HBITMAP

This is a discussion on HICON to HBITMAP within the Windows Programming forums, part of the Platform Specific Boards category; Is there a way to convert HICON to HBITMAP ? thank you....

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    HICON to HBITMAP

    Is there a way to convert HICON to HBITMAP?


    thank you.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,262
    Off the top of my head, use DrawIcon to draw it to a DC with a bitmap selected into it and there you go.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Yes. Use GetIconInfo or draw the icon to a bitmap using DrawIconEx. See threads.

  4. #4
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    wow, it's so short and simple... and not DCs. Thank you.

    Code:
    HBITMAP hBitmap;
    HICON hIcon;
    ICONINFO iconinfo;
    
    hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ICON));
    GetIconInfo(hIcon, &iconinfo);
    hBitmap = iconinfo.hbmColor;
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    2
    This's what i'm finding. Thank so much if it work.

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    2
    Quote Originally Posted by Devil Panther View Post
    wow, it's so short and simple... and not DCs. Thank you.

    Code:
    HBITMAP hBitmap;
    HICON hIcon;
    ICONINFO iconinfo;
    
    hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_ICON));
    GetIconInfo(hIcon, &iconinfo);
    hBitmap = iconinfo.hbmColor;
    seem that it does not work!!??? I changed hbmColor with SetBitmapBits and there was no thing changed.

  7. #7
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    No, it's wrong.
    You must pass throug a DIB Section or a comp. DC.
    See MSDN (WSDK) or Google Groups for the usual methods (comp.os.ms-windows.programmer.win32
    and others)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading bitmap file into a HBITMAP
    By wind_addict in forum Windows Programming
    Replies: 9
    Last Post: 11-17-2007, 09:42 AM
  2. drawing on bitmaps
    By eth0 in forum Windows Programming
    Replies: 2
    Last Post: 03-24-2006, 04:56 PM
  3. HBITMAP in Class
    By Born_2B_Alone in forum Windows Programming
    Replies: 1
    Last Post: 10-09-2004, 05:47 PM
  4. HBITMAP from hdc
    By solar3147 in forum Windows Programming
    Replies: 5
    Last Post: 07-02-2003, 01:59 AM
  5. Static HBITMAP
    By Hunter2 in forum C++ Programming
    Replies: 4
    Last Post: 07-01-2002, 06:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21