如何在 Visual Studio 2008 中设置应用程序的图标?
如何在 Visual Studio 2008 中设置 C++ 应用程序的可执行图标?
How do I set the executable icon for my C++ application in visual studio 2008?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这就是您在 Visual Studio 2010 中执行此操作的方式。
因为它很挑剔,所以实际上这可能会非常痛苦,因为您正在尝试做一些如此简单的事情,但它并不简单,而且有许多问题 Visual Studio 没有告诉您。 如果在任何时候你感到生气或者想要咬牙切齿地尖叫,无论如何,请这样做。
陷阱:
1) 打开VIEW> 资源视图(位于视图菜单中间),或按Ctrl+Shift+E 让它出现。
2) 在资源视图中,右键单击项目名称并说ADD> RESOURCE...
3) 假设您已经自己生成了 .ico 文件,从出现的垃圾列表中选择图标,然后单击导入 >。
4) 在此对话框中,未列出
*.ico
文件,并且您无法使用常规 PNG 或 JPG 图像作为图标,因此将文件过滤器更改为*.ico
使用下拉菜单。 误导性的用户界面,我知道,我知道。5) 如果您现在编译项目,它会自动将ID最小的.ico(如
resource.h
中所列)粘贴为.exe 文件的图标。6) 如果您出于某种原因将一堆 ICO 文件加载到项目中,请确保您希望 Visual Studio 使用的 .ico 在
resource.h
中具有最低 id 。 您可以毫无问题地手动编辑此文件,例如。
使用 IDI_ICON1
现在使用 IDI_ICON2。
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.
首先转到资源视图(从菜单:视图 --> 其他窗口 --> 资源视图)。 然后在资源视图中浏览资源(如果有)。 如果已经存在由 Visual Studio 添加的 Icon 类型的资源,则打开并编辑它。 否则,右键单击并选择添加资源,然后添加新图标。
使用嵌入式图像编辑器来编辑现有或新图标。 请注意,图标可以包含多种类型(尺寸),可从“图像”菜单中选择。
然后编译你的项目并查看效果。
请参阅:http://social.microsoft .com/Forums/en-US/vcgeneral/thread/87614e26-075c-4d5d-a45a-f462c79ab0a0
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
重要的是,你想要显示为应用程序图标(在标题栏和任务栏中)的图标必须是资源脚本文件中的第一个图标
该文件位于res文件夹中,名称为(applicationName) .rc
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
您按照 bobobobo 所说在资源中添加 .ico,然后在主对话框的构造函数中进行修改:
m_hIcon = AfxGetApp()->LoadIcon(ICON_ID_FROM_RESOURCE.H);
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);
如果您使用的是 .NET,请在解决方案资源管理器中右键单击您的程序并选择属性。 在资源部分下,选择图标和清单,然后浏览到图标的位置。
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.
我不知道 VS 2008 中的 VB.net 是否有什么不同,但以上都不适合我。 在解决方案资源管理器中双击我的项目将显示如下所示的窗口。 选择左侧的应用程序,然后使用组合框浏览找到您的图标。 构建后,它应该显示在您的 exe 文件中。
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.