如何在visual studio 2008中设置应用程序的图标?

时间:2022-08-29 23:16:11

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

如何在visual studio 2008中设置c++应用程序的可执行图标?

6 个解决方案

#1


30  

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.

首先进入资源视图(从菜单:View—>其他窗口—>资源视图)。然后在资源视图中浏览资源,如果有的话。如果已经有一个由Visual Studio添加的图标类型资源,那么打开并编辑它。否则右键单击并选择Add Resource,然后添加一个新的图标。

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

参见:http://social.microsoft.com/forums/en us/vcgeneral/thread/87614e26 - 075 c - 4 - d5d a45a f462c79ab0a0

#2


53  

This is how you do it in Visual Studio 2010.

这就是在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.

因为它很挑剔,这可能会很痛苦,事实上,因为你正在尝试做一些非常简单的事情,但是它并不是直接的,有很多问题是Visual Studio没有告诉你的。如果你在任何时候感到愤怒,或者你想把你的牙齿埋进一个2×4的洞里尖叫,请一定要这样做。

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.
  • 您需要使用.ico文件。您不能使用PNG图像文件为您的可执行文件的图标,它将不会工作。您必须使用ico。有一些web实用程序可以将图像转换为.ico文件。
  • The ico used for your exe will be the ico with the LOWEST RESOURCE ID. In order to change the .ico
  • 用于exe的ico将是具有最低资源ID的ico。

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

1)打开VIEW > RESOURCE VIEW(在VIEW菜单中间),或者按Ctrl+Shift+E显示。

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

2)在资源视图中,右键单击项目名称,输入添加>资源…

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

3)假设您已经自己生成了一个.ico文件,从出现的垃圾列表中选择图标,然后单击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.

4)在这个对话中*。ico文件没有列出,你不能使用一个普通的PNG或者JPG图片作为图标,所以将文件过滤器改为*。使用下拉图标。误导用户界面,我知道,我知道。

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.

5)如果您现在编译您的项目,它会自动将.ico与最低ID(如resource.h所列)作为.exe文件的图标。

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

6)如果出于某种原因将一堆ICO文件加载到项目中,请确保您希望Visual Studio使用的是resource.h中的最低id。您可以手工编辑这个文件,没有问题

Eg.

如。

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

IDI_ICON1 is used

IDI_ICON1使用

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

Now IDI_ICON2 is used.

现在IDI_ICON2使用。

#3


8  

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

文件在res文件夹中,并被命名为(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"

#4


2  

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.

我不知道VB.net在VS 2008是否有什么不同,但以上这些对我都不起作用。在解决方案资源管理器中双击我的项目,会弹出如下所示的窗口。在左边选择Application,然后使用combobox浏览图标。构建之后,它应该出现在exe文件中。

如何在visual studio 2008中设置应用程序的图标?

#5


2  

You add the .ico in your resource as bobobobo said and then in your main dialog's constructor you modify:

将.ico添加到资源中,bobobobo说,然后在主对话框的构造函数中修改:

m_hIcon = AfxGetApp()->LoadIcon(ICON_ID_FROM_RESOURCE.H);

m_hIcon = AfxGetApp()- > LoadIcon(ICON_ID_FROM_RESOURCE.H);

#6


0  

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.

如果您正在使用。net,在解决方案资源管理器中右键单击您的程序并选择properties。在资源部分选择图标和清单,然后浏览到图标的位置。

#1


30  

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.

首先进入资源视图(从菜单:View—>其他窗口—>资源视图)。然后在资源视图中浏览资源,如果有的话。如果已经有一个由Visual Studio添加的图标类型资源,那么打开并编辑它。否则右键单击并选择Add Resource,然后添加一个新的图标。

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

参见:http://social.microsoft.com/forums/en us/vcgeneral/thread/87614e26 - 075 c - 4 - d5d a45a f462c79ab0a0

#2


53  

This is how you do it in Visual Studio 2010.

这就是在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.

因为它很挑剔,这可能会很痛苦,事实上,因为你正在尝试做一些非常简单的事情,但是它并不是直接的,有很多问题是Visual Studio没有告诉你的。如果你在任何时候感到愤怒,或者你想把你的牙齿埋进一个2×4的洞里尖叫,请一定要这样做。

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.
  • 您需要使用.ico文件。您不能使用PNG图像文件为您的可执行文件的图标,它将不会工作。您必须使用ico。有一些web实用程序可以将图像转换为.ico文件。
  • The ico used for your exe will be the ico with the LOWEST RESOURCE ID. In order to change the .ico
  • 用于exe的ico将是具有最低资源ID的ico。

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

1)打开VIEW > RESOURCE VIEW(在VIEW菜单中间),或者按Ctrl+Shift+E显示。

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

2)在资源视图中,右键单击项目名称,输入添加>资源…

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

3)假设您已经自己生成了一个.ico文件,从出现的垃圾列表中选择图标,然后单击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.

4)在这个对话中*。ico文件没有列出,你不能使用一个普通的PNG或者JPG图片作为图标,所以将文件过滤器改为*。使用下拉图标。误导用户界面,我知道,我知道。

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.

5)如果您现在编译您的项目,它会自动将.ico与最低ID(如resource.h所列)作为.exe文件的图标。

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

6)如果出于某种原因将一堆ICO文件加载到项目中,请确保您希望Visual Studio使用的是resource.h中的最低id。您可以手工编辑这个文件,没有问题

Eg.

如。

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

IDI_ICON1 is used

IDI_ICON1使用

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

Now IDI_ICON2 is used.

现在IDI_ICON2使用。

#3


8  

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

文件在res文件夹中,并被命名为(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"

#4


2  

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.

我不知道VB.net在VS 2008是否有什么不同,但以上这些对我都不起作用。在解决方案资源管理器中双击我的项目,会弹出如下所示的窗口。在左边选择Application,然后使用combobox浏览图标。构建之后,它应该出现在exe文件中。

如何在visual studio 2008中设置应用程序的图标?

#5


2  

You add the .ico in your resource as bobobobo said and then in your main dialog's constructor you modify:

将.ico添加到资源中,bobobobo说,然后在主对话框的构造函数中修改:

m_hIcon = AfxGetApp()->LoadIcon(ICON_ID_FROM_RESOURCE.H);

m_hIcon = AfxGetApp()- > LoadIcon(ICON_ID_FROM_RESOURCE.H);

#6


0  

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.

如果您正在使用。net,在解决方案资源管理器中右键单击您的程序并选择properties。在资源部分选择图标和清单,然后浏览到图标的位置。