How to convert HICON to HBITMAP in VC++?

后端 未结 4 1785
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 19:18

How to convert HICON to HBITMAP in VC++?

I know this is an FAQ but all the solutions I\'ve found on Google don\'t work. What I need is a function which takes a param

4条回答
  •  情话喂你
    2020-12-10 19:38

    this code do it:

    HICON hIcon = (HICON)LoadImage(instance, MAKEINTRESOURCEW(IDI_ICON), IMAGE_ICON, width, height, 0);
    ICONINFO iconinfo;
    GetIconInfo(hIcon, &iconinfo);
    HBITMAP hBitmap = iconinfo.hbmColor;
    

    and this is the code in the *.rc file:

    IDI_ICON ICON "example.ico"
    

    and this is the code in the *.h file:

    #define IDI_ICON 4000
    

提交回复
热议问题