Jump to content
  • Advertisement

Archived

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

PhilAb

Adding icons onto the buttons in a dialog box

This topic is 5123 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I got a problem in adding icons onto the buttons in a dialog box. I have a button on my dialog box of CButton type. In code I am adding an icon for the button using SetIcon method. But that gives an error message saying "SetIcon'' : cannot convert parameter 1 from ''const int'' to ''struct HICON__ *''", I have searched MSDN but the only found method is SetIcon, which should have set the icon. Can anyone please help me out in this regard. ? Thanks in advance.. :-)

Share this post


Link to post
Share on other sites
Advertisement
Use LoadIcon(). If you want to use a default Windows icon, do:

myButton.SetIcon(LoadIcon(NULL, IDI_APPLICATION)); // Replace IDI_APPLICATION with whatever system icon you want to use

Or, if you want to load an icon from a resource, do:

myButton.SetIcon(LoadIcon(hInstance, IDI_MYICON)); // hInstance is the HINSTANCE variable in WinMain, IDI_MYICON is the resource ID of your icon

Share this post


Link to post
Share on other sites
I tried the LoadIcon method too, but still the icon is not displayed. Can the second parameter be the icon id that is in the resource under icon folder ?

The button is of type CButton or should I derive from some other class.. ?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!