● XRC 描述外部资源
#include "wx/wx.h"
#include "wx/xrc/xmlres.h"
bool MyApp::OnInit()
{
wxXmlResource::Get()->InitAllHandlers();
wxXmlResource::Get()->Load(wxT("myframe.xrc"));
wxFrame * frame = wxXmlResource::Get()->LoadFrame(NULL, wxT("frame_name"));
frame->Show(true);
return true;
}
● XRS 二进制资源
$ wxrc -o myframe.xrs myframe.xrc
#include "wx/wx.h"
#include "wx/xrc/xmlres.h"
#include "wx/fs_arc.h"
bool MyApp::OnInit()
{
wxFileSystem::AddHandler(new wxArchiveFSHandler);
wxXmlResource::Get()->InitAllHandlers();
wxXmlResource::Get()->Load(wxT("myframe.xrs"));
wxFrame * frame = wxXmlResource::Get()->LoadFrame(NULL, wxT("frame_name"));
frame->Show(true);
return true;
}
● CPP 内嵌资源
$ wxrc -c -o myframe.cpp myframe.xrc
#include "wx/wx.h"
#include "wx/xrc/xmlres.h"
extern void InitXmlResource();
bool MyApp::OnInit()
{
wxXmlResource::Get()->InitAllHandlers();
InitXmlResource();
wxFrame * frame = wxXmlResource::Get()->LoadFrame(NULL, wxT("frame_name"));
frame->Show(true);
return true;
}