一、使用xpm图标文件
#include "simple.h"
#include "web.xpm"//这句必须加上。web.xpm是图标文件
Simple::Simple(const wxString& title)
:wxFrame(NULL,wxID_ANY,title,wxDefaultPosition,wxDefaultSize)
{
SetIcon(wxIcon(web_xpm));//这个好用,必须配合include "web.xpm"使用
Centre();
}
如果不使用#include "web.xpm"
则可以如下方式使用
wxImage::AddHandler(new wxXPMHandler);
SetIcon(wxIcon("abe.xpm",wxBITMAP_TYPE_XPM));
二、使用ico图标文件
#include "simple.h"
Simple::Simple(const wxString& title)
:wxFrame(NULL,wxID_ANY,title,wxDefaultPosition,wxDefaultSize)
{
SetIcon(wxIcon("acrobat.ico",wxBITMAP_TYPE_ICO));//这个也可以
Centre();
}
三、使用png图标文件
#include "simple.h"
Simple::Simple(const wxString& title)
:wxFrame(NULL,wxID_ANY,title,wxDefaultPosition,wxDefaultSize)
{
wxInitAllImageHandlers();//句1,与句2任选其一即可
// wxImage::AddHandler(new wxPNGHandler);//句2,与句1任选其一即可
SetIcon(wxIcon("accerciser.png",wxBITMAP_TYPE_PNG));
Centre();
}