How do I set the executable icon for my C++ application in visual studio 2008?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
相关文章
- How to show location of errors, references to memb
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- How to add external file to application files ( cl
- Which is the best way to multiply a large and spar
- How to track MongoDB requests from a console appli
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
I don't know if VB.net in VS 2008 is any different, but none of the above worked for me. Double-clicking My Project in Solution Explorer brings up the window seen below. Select Application on the left, then browse for your icon using the combobox. After you build, it should show up on your exe file.
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
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
If you're using .NET, 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.
You add the .ico in your resource as bobobobo said and then in your main dialog's constructor you modify:
m_hIcon = AfxGetApp()->LoadIcon(ICON_ID_FROM_RESOURCE.H);
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:
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 problemsEg.
IDI_ICON1 is used
Now IDI_ICON2 is used.