动态设置IDR_MAINFRAME图标 [英] dynamically set the IDR_MAINFRAME icon

查看:649
本文介绍了动态设置IDR_MAINFRAME图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何在VC6文档视图应用程序中动态设置程序图标吗?标题栏左上方的图标是16x16 IDR_MAINFRAME图标,在桌面上为可执行文件显示的图标是32x32 IDR_MAINFRAME图标.同样,用该程序打开的桌面上显示的任何文件都将带有与该文件一起显示的图标.我有一个应用程序,我想让用户选择一个图标,然后在标题栏的左上方显示该图标,并将与桌面上任何生成的文件关联的图标设置为所选图标.因此,听起来好像将IDR_MAINFRAME图标动态更改为另一个图标将具有我尝试实现的行为.我拥有用户可以在我的资源中选择的所有图标(IDI_ICON1,IDI_ICON2等).谢谢.

Does anyone know how to set the program icon dynamically in a VC6 doc-view application? The icon in the upper left of the title bar is the 16x16 IDR_MAINFRAME icon, and the icon shown for the executable on the desktop is the 32x32 IDR_MAINFRAME icon. Also any file shown on the desktop opened with that program will have the icon displayed with that file. I have an application where I want to let the user select an icon, then I want to show that icon in the upper left of the title bar, and also set the icon associated with any generated files on the desktop to the selected icon. So it sounds like dynamically changing the IDR_MAINFRAME icon to another icon would have the behavior I''m trying to implement. I have all the icons the user can select in my resource (IDI_ICON1, IDI_ICON2, etc). Thanks.

推荐答案

您要问3种不同的事情

我将说明如何更改应用程序窗口的图标.
(我不习惯使用MFC,因此我将使用一些API)

使用
从资源中加载图标
You''re asking 3 different things

I''ll explain how to change the application window''s icon.
(I''m not used to working with MFC, so i''ll use some API)

Load the icon from your resource using
HICON icn = ::LoadIcon(::GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ICONx))



您可以使用SetClassLong
设置图标



You may set the icon using SetClassLong

::SetClassLong(hWnd,GCL_HICON,(LONG)icn);



您必须使用Shell Links api设置桌面快捷方式的图标.检查msdn以获得一些示例

要设置应用程序的文档图标,请修改注册表
(假设您文档的扩展名是.abc)
在此路径中设置图标
HKEY_CLASSES_ROOT \ .abc \ DefaultIcon
该值将是您的可执行文件的路径,后跟一个数字
例如:C:\ YourApp.exe,0
其中数字0(或1,2)是可执行文件中图标资源的订单号.
只需查看一些注册表项即可了解



You must use the Shell Links api to set your desktop shortcut''s icon. Check msdn for some examples

To set your application''s documents'' icons, modify the registry
(assuming your document''s extension is .abc)
Set icons in this path
HKEY_CLASSES_ROOT\.abc\DefaultIcon
The value will be the path to your executable file, followed by a number
Eg: C:\YourApp.exe,0
where the number 0 (or 1,2) is the order number of the icon resources in your executable.
Just check out some registry keys to understand


这篇关于动态设置IDR_MAINFRAME图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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