如何为我的应用和按钮分配图标? [英] How to assign icons to my app and buttons?

查看:85
本文介绍了如何为我的应用和按钮分配图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在Visual Studio 2012 Win-Forms C ++ / CLI项目中对图标有两个问题:



1.)我创建了MyIcon.ico并将其添加到应用程序的资源文件中:



App.rc:

IDI_MAIN ICONMyIcon.ico



resource.h:

#define IDI_MAIN 1



但我的应用程序显示VS标准图标而不是我的。



2.)我有一张表格ToolStrip和ToolStripButton,我已经为我的按钮分配了一个图标(Save.bmp)。但是,是否有可能将预定义的Windows标准图标分配给我的控件?

在应用程序的资源文件中,显示了许多预定义(但未使用)的只读符号,例如: ID_FILE_SAVE。但是如何将这个ID(图标)分配给我的按钮?



Thanx

Volker

解决方案
1。假设.rc被编译并且.res链接,它可能是Windows缓存图标的旧问题,并且在更新/链接目标时不显示正确的图标。两个想法来检验这个假设; 1.在资源管理器中选择exe上的属性。这可以从中提取正确的图标。 2.将exe复制到一个新名称,看看是否也无法显示图标。



2.查看LoadIcon的文档(也许还有LoadImage) )。你确实可以获得系统提供的图标至少前者的HICON。


1。检查图标文件是否在当前目录中,并且也是资源脚本中的第一个 ICON 条目。



2.只要在主代码中使用相同的名称,就可以在脚本中使用任何预定义的资源值。您还应确保您自己的任何定义都不使用与预定义名称相同的值。


Hi at all,

I’ve two questions to icons in a Visual Studio 2012 Win-Forms C++/CLI project:

1.) I’ve created "MyIcon.ico" and added it to app’s resource files:

App.rc:
IDI_MAIN ICON " MyIcon.ico"

resource.h:
#define IDI_MAIN 1

But my application shows the VS standard icon instead of mine.

2.) I’ve a form with a ToolStrip and a ToolStripButton and I’ve assigned an icon (Save.bmp) to my button. But isn’t there a possibility to assign predefined Windows standard icons to my controls?
In the app’s resource file there are shown lots of predefined (but not used) read-only symbols, e.g. ID_FILE_SAVE. But how to assign this ID (icon) to my button?

Thanx
Volker

解决方案

1. Assuming the .rc is compiled and the .res linked, it could be the old problem of Windows caching icons, and not displaying the right icon when updating/linking a target. Two ideas to test that hypothesis; 1. select Properties on the exe in Explorer. That could extract the correct icon from it. 2. Copy the exe to a new name and see if that also fails to display the icon.

2. Have a look at the documentation for LoadIcon (maybe also LoadImage). You can indeed get a HICON for the system-provided icons frmo at least the former.


1. Check that the icon file is in the current directory, and is also the first ICON entry in the resource script.

2. You may use any of the predefined resource values in your scripts, as long as you use the same names in your main code. You should also ensure that any of your own definitions do not use the same values as the predefined names.


这篇关于如何为我的应用和按钮分配图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆