Solved

How to put an icon on a button

Posted on 1998-12-31
4
401 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 96
substring method in java 1 120
centeredAverage challenge 8 165
Path of Workbook 3 77
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

778 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