wxWidgets标题栏图标 [英] wxWidgets Title bar icon

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

问题描述

我想更改显示在框架左上角的默认图标.我尝试了许多方法-xpm,ico,bmp,按照建议SetIcon(wxIcon(wxT("icon.xpm"))); >这里.
我尝试了不同的图标尺寸,分别为16x16、24x24和32x32.
我还尝试在resource.rc文件中添加 MYICON1 ICON"Logo.ico" ,在resource.h文件中添加 #define MYICON1 101 SetIcon(wxIcon(MYICON1)); 到框架构造函数..

顺便说一句,我正在Visual Studio 2010上使用wxwidgets 2.8

I want to change the default icon that shows up at the top left corner of the frame. I have tried many approaches- xpm, ico, bmp, using SetIcon(wxIcon(wxT("icon.xpm"))); as suggested here.
I tried different icon sizes, 16x16, 24x24 and 32x32.
I've also tried adding MYICON1 ICON "Logo.ico" in the resource.rc file, #define MYICON1 101 in the resource.h file and SetIcon(wxIcon(MYICON1)); to the frame constructor..

btw, i'm using wxwidgets 2.8 on visual studio 2010

我还尝试在resource.rc文件中添加 MYICON1 ICON"Logo.ico" ,在resource.h文件中添加 #define MYICON1 101 SetIcon(wxIcon(MYICON1)); 到框架构造函数.

I've also tried adding MYICON1 ICON "Logo.ico" in the resource.rc file, #define MYICON1 101 in the resource.h file and SetIcon(wxIcon(MYICON1)); to the frame constructor..

使用这种方法,在wxIcon(int)构造函数中出现错误.

With this approach, I get an error in the wxIcon(int) constructor..

1> xsframe.cpp(17):错误C2248:'wxString :: wxString':无法访问在类'wxString'中声明的私有成员
1> C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ include \ wx/string.h(682):请参见'wxString :: wxString'的声明
1> C:\ Program Files(x86)\ Microsoft Visual Studio 10.0 \ VC \ include \ wx/string.h(659):请参见'wxString'的声明

1>xsframe.cpp(17): error C2248: 'wxString::wxString' : cannot access private member declared in class 'wxString'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\wx/string.h(682) : see declaration of 'wxString::wxString'
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\wx/string.h(659) : see declaration of 'wxString'

PS,xsframe是我的主框架.我正在尝试更改其图标.

PS, xsframe is my main frame. whose icon i'm trying to change.

推荐答案

我引用了

您可以使用wxFrame :: SetIcon设置主机的图标.应用可以通过向.rc文件中添加新的图标资源来更改图标:

You can set your main frame's icon with wxFrame::SetIcon. Application icon can be changed by adding a new icon resource to your .rc file:

appicon ICON "myapp.ico"
#include "wx/msw/wx.rc"

请注意,此图标必须是.rc文件中的第一个图标,并且当您按字母顺序对图标进行排序时,必须是第一个.这是因为MS开发人员无法考虑如何确定应用程序的图标:它是Windows 9x下.rc文件中的第一个图标在NT下按字母顺序排列第一个(反之亦然).

Note that this icon must be the first icon in your .rc file and it must be the first one when you sort your icons alphabetically. This is because MS developers weren't able to make their mind on how to determine app's icon: it is the first one in .rc file under Windows 9x and the alphabetically first one under NT (or vice versa).

大多数人通常会错过这一点.希望能解决问题.

Most people usually miss this. Hope that fixes things.

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

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