Solved

How to put an icon on a button

Posted on 1998-12-31
4
402 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:backdraf
  • 2
4 Comments
 

Expert Comment

by:nari
ID: 1327083
Use LoadIcon funtion to convert const int to struct HICON_ then it works.
0
 

Author Comment

by:backdraf
ID: 1327084
Could you show me an example of this?
0
 

Author Comment

by:backdraf
ID: 1327085
Could you show me an example of this?
0
 
LVL 6

Accepted Solution

by:
thresher_shark earned 50 total points
ID: 1327086
This is what you want to do:

m_button_close.SetIcon (AfxGetApp ()->LoadIcon (IDI_DIALOGBAR);

Simply copy that code at the point you want the icon to load, and you are all set.  If you have further questions, please feel free to ask.  Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 37
Excel Use VBA to get user's Mac Address for their computer 5 344
How to determine file rename from EventLog ? 2 58
has22 challenge 11 107
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question