Link to home
Start Free TrialLog in
Avatar of backdraf
backdraf

asked on

How to put an icon on a button

I want to put an icon on a button. the button was created using visual C++ and was done visually(i didn't right the code to create it i just dragged and dropped it). I used classwizard to attach a variable named m_button_close to it of type CButton. then i went in and manually wrote the following code:

      m_button_close.SetIcon(IDI_DIALOGBAR);

IDI_DIALOGBAR is an icon i added to the project. when i try to compile this progie it gives the following error:

error C2664: 'SetIcon' : cannot convert parameter 1 from 'const int' to 'struct HICON__ *'

whats up with that? what am i doing wrong?
Avatar of nari
nari

Use LoadIcon funtion to convert const int to struct HICON_ then it works.
Avatar of backdraf

ASKER

Could you show me an example of this?
Could you show me an example of this?
ASKER CERTIFIED SOLUTION
Avatar of thresher_shark
thresher_shark

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial