Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 475
Ronny Vindenes Avatar asked Nov 26 '08 13:11

Ronny Vindenes


People also ask

How do I change the icon for a program in Visual Studio?

On the menu bar, choose Project > Properties. When the Project Designer appears, choose the Application tab. (Visual Basic)—In the Icon list, choose an icon (. ico) file.

How do I add an icon to a button in Visual Studio?

create an image. set the source of the image to the right file of your resources (e.g. a . png file that you included to your project) drag the image over the button. A text shows that asks you to press ALT to replace the text of the button with the image.


1 Answers

This is how you do it in Visual Studio 2010.

Because it is finicky, this can be quite painful, actually, because you are trying to do something so incredibly simple, but it isn't straight forward and there are many gotchas that Visual Studio doesn't tell you about. If at any point you feel angry or like you want to sink your teeth into a 2 by 4 and scream, by all means, please do so.

Gotchas:

  • You need to use an .ico file. You cannot use a PNG image file for your executable's icon, it will not work. You must use .ico. There are web utilities that convert images to .ico files.
  • The ico used for your exe will be the ico with the LOWEST RESOURCE ID. In order to change the .ico

1) Open VIEW > RESOURCE VIEW (in the middle of the VIEW menu), or press Ctrl+Shift+E to get it to appear.

2) In Resource view, right click the project name and say ADD > RESOURCE...

3) Assuming you have already generated an .ico file yourself, choose Icon from the list of crap that appears, then click IMPORT.

4) At this dialog *.ico files aren't listed, and you can't use a regular PNG or JPG image as an icon, so change the file filter to *.ico using the dropdown. Misleading UI, I know, I know.

5) If you compile your project now, it will automatically stick the .ico with the lowest ID (as listed in resource.h) as the icon of your .exe file.

6) If you load a bunch of ICO files into the project for whatever reason, be sure the .ico you want Visual Studio to use has the lowest id in resource.h. You can edit this file manually with no problems

Eg.

//resource.h #define IDI_ICON1                       102 #define IDI_ICON2                       103 

IDI_ICON1 is used

//resource.h #define IDI_ICON1                       106 #define IDI_ICON2                       103 

Now IDI_ICON2 is used.

like image 169
bobobobo Avatar answered Oct 06 '22 12:10

bobobobo