在wxMSW中设置窗口的左上角图标
我正在开发一个 wxWidgets 项目(2.9 分支)。我正在使用 gcc 和 makefile - 我在 Visual Studio 中发现的大部分问题。
问题是,我用 IcoFX 创建了一个图标,它包含几种不同大小的图标,包括应该显示在窗口角落的 16x16 图标。该图标确实显示在 Windows 7 任务栏中,但不在窗口一角或 Alt+Tab 菜单中。
我的资源文件如下所示:
#include "wx/msw/wx.rc"
1 ICON "images/icon-win.ico"
无论我将什么作为图标的标识符(尝试过 1、0、字符串、wx***),它都不会改变任何内容。
我使用 Windres 将资源文件编译为 COFF 格式,然后将其与最终的可执行文件链接。
我也尝试过 wxFrame::SetIcon,但也不起作用。
设置窗口图标有什么技巧吗?我已经看到了几种涉及 Windows API 的方法,但如果没有必要,我宁愿不这样做。我认为当您将其放入资源文件中时它应该会自动显示。
I'm working on a project with wxWidgets (the 2.9 branch). I'm using gcc and makefiles - most of the questions I've found on this deal with Visual Studio.
The problem is, I've created an icon with IcoFX, and it includes several different sizes of icon, including the 16x16 icons that should show up in the corner of the window. The icon does show up in the Windows 7 task bar, but not in the corner of the window or in the Alt+Tab menu.
My resource file looks like this:
#include "wx/msw/wx.rc"
1 ICON "images/icon-win.ico"
No matter what I put as the icon's identifier (tried 1, 0, strings, wx***) it doesn't change anything.
I am using windres to compile the resource file to COFF format, which is then linked in with the final executable.
I've also tried wxFrame::SetIcon, which hasn't worked either.
Is there a trick to setting the window's icon? I've seen a couple ways to do it that involve the Windows API, but I'd rather not go there if I don't have to. I thought it was supposed to show up automatically when you put it in the resources file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将此行添加到您的资源文件中:
将此行添加到您的框架构造函数中
Add this line to your resource file:
Add this line to your frame constructor
试试这个
frame->SetIcon(wxIcon(wxT("icon.ico"), wxBITMAP_TYPE_ICO));
Try this
frame->SetIcon(wxIcon(wxT("icon.ico"), wxBITMAP_TYPE_ICO));
正如您所发现的,将图标放入资源文件中意味着它会显示在任务栏上并作为可执行图标。要将其设置为框架图标,您需要执行以下操作:
As you have found putting the icon in the resource file means it shows up on the task bar and as the executable icon. To set it as the frame icon you need to do the following: