views:

11398

answers:

5

How do I set the executable icon for my C++ application in visual studio 2008?

+7  A: 

First go to Resource View (from menu: View --> Other Window --> Resource View). Then in Resource View navigate through resources, if any. If there is already a resource of Icon type, added by Visual Studio, then open and edit it. Otherwise right-click and select Add Resource, and then add a new icon.

Use the embedded image editor in order to edit the existing or new icon. Note that an icon can include several types (sizes), selected from Image menu.

Then compile your project and see the effect.

See: http://social.microsoft.com/Forums/en-US/vcgeneral/thread/87614e26-075c-4d5d-a45a-f462c79ab0a0

Jason Stevenson
+1 - Thank you.
lucifer
+1  A: 

This is a slight aside, but if you're looking for a good icon editor you might like to try Axialis IconWorkshop Lite, a free plug-in for Visual Studio 2008

Richard Ev
+3  A: 

The important thing is that the icon you want to be displayed as the application icon ( in the title bar and in the task bar ) must be the FIRST icon in the resource script file

The file is in the res folder and is named (applicationName).rc

/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
(icon ID )          ICON                    "res\\filename.ico"
ravenspoint
This is only a requirement for the shell icon of the program file, i.e. the one shown in Explorer. The actual window icon can be set programatically to any icon, although the default is the first one.
efotinis
Using IDI_MAIN_ICON for the icon id seems to work. I've had problems if I just picked a random number. So like:IDI_MAIN_ICON ICON "icon.ico"
Tod
+1  A: 

In the solutions explorer right click your program and select properties. Under the resource section select Icon and manifest, then browse to the location of your icon.

which version is this?
ina
This does not work in 2010
lucifer
A: 

Hi, I'm trying to set my application icon but it's not working fine.

I've set it using the resource editor, and now I have this line in my .rc file:

IDI_ICON1 ICON "images\\machs5.ico"

When I compile the project, the '.exe" file is OK, with the icon showing correctly. However, when I run the application, that icon is not shown neither in the title bar nor in the task bar... :(

Any ideas of what I'm doing wrong?

astu