Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How to put a standard windows icon on a button

Posted on 2004-11-09
Medium Priority
Last Modified: 2013-11-20
How do I put a stardard windows icon on a button?

I have a dlg based application and want to put the 'browse folders' icon on a button.

Question by:galneweinhaw
1 Comment
LVL 45

Accepted Solution

AndyAinscow earned 2000 total points
ID: 12536821
CButton myButton;

// Create an icon button.
myButton.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_ICON,
   CRect(10,10,60,50), pParentWnd, 1);

// Set the icon of the button to be the system question mark icon.
myButton.SetIcon( ::LoadIcon(NULL, IDI_QUESTION) );

You will have to create your own icon which is a 'copy' of the picture on the browse folders icon and load it onto the button as per above code.  (You can also create the button in the resource editor and set the style there as icon).

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

577 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