Creating a button w/ icon - MFC

Started by
1 comment, last by HellspawnXIII 20 years, 11 months ago
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.
HellspawnXIII"There's a lot of stuff in this world that needs stepping on."
Advertisement
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.
HellspawnXIII"There's a lot of stuff in this world that needs stepping on."
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.

This topic is closed to new replies.

Advertisement