Archived

This topic is now archived and is closed to further replies.

HellspawnXIII

Creating a button w/ icon - MFC

Recommended Posts

Does anyone know how to create a button (CButton) with an icon in it instead of text? I''ve done some research and so far I have: h_icon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_CLOSE)); m_bClose.SetIcon(h_icon); Also, in the resource editor, I have the the Icon style box checked. Everything compiles fine, but my button is empty! Any thoughts?
HellspawnXIII Build a man a fire, and he''ll be warm for a day. Set him on fire, and he''ll be warm for the rest of his life.

Share this post


Link to post
Share on other sites
Nevermind, I found the solution:

The NULL in the function LoadIcon shouldn''t be NULL - it has to be the instance of my app.

Silly me.


HellspawnXIII
Build a man a fire, and he''ll be warm for a day. Set him on fire, and he''ll be warm for the rest of his life.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Correct, hInstance should be NULL ONLY while loading a non-standard icon ... taken directly from VS .NET SDK:



hInstance

[in] Handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be NULL when a standard icon is being loaded.

Share this post


Link to post
Share on other sites