简体   繁体   English

Win32 应用程序找不到 window 的图标

[英]Win32 application not finding icon for window

I created a icon as a resource我创建了一个图标作为资源

解决方案资源管理器中的图标

I checked explorer and it works just fine, my exe now has that icon我检查了资源管理器,它工作正常,我的 exe 现在有那个图标

Next, I used hIcon to set the icon of my window but it says that IDI_ICON1 is undefined接下来,我使用 hIcon 设置我的 window 的图标,但它说 IDI_ICON1 未定义在此处输入图像描述

Code:代码:

wc.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_ICON1));

Is there any idea of why this is happening?知道为什么会这样吗?

Symbolic constants for resource identifiers (such as IDI_ICON1 ) are usually stored in a separate header file called Resource.h by default.默认情况下,资源标识符(例如IDI_ICON1 )的符号常量通常存储在名为Resource.h的单独 header 文件中。 This allows both the resource script (.rc file) as well as source code to access the same symbols.这允许资源脚本(.rc 文件)和源代码访问相同的符号。

To use the constants in source code you need to introduce them through an #include directive.要在源代码中使用常量,您需要通过#include指令引入它们。 Otherwise the compiler is unable to find them, as the error messages indicates.否则编译器无法找到它们,如错误消息所示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM