# include "wx/wx.h"
# include "mondrian.xpm"
// 定义应用程序类
class MyApp:public wxApp
{
public :
// 这个函数将会在程序启动的时候被调用
virtual bool OnInit();
};
// 定义主窗口类
class MyFrame:public wxFrame
{
public:
// 主窗口类的构造函数
MyFrame(const wxString & title);
// 事件处理函数
void OnQuit(wxCommandEvent & event);
void OnAbout( wxCommandEvent & event);
private:
// 声明事件表
DECLARE_EVENT_TABLE()
};
// 有了这一行就可以使用 MyApp & wxGetApp了()
DECLARE_APP(MyApp)
// 告诉主应用程序是哪个类wxWidgets
IMPLEMENT_APP(MyApp)
// 初始化程序
bool MyApp::OnInit()
{
// 创建主窗口
MyFrame *frame = new MyFrame(wxT(" Minimal wxWidgets App"));
// 显示主窗口
frame->Show(true);
// 开始事件处理循环
return true ;
}
// 类的事件表MyFrame
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
EVT_MENU(wxID_ABOUT,MyFrame::OnAbout)
EVT_MENU(wxID_EXIT,MyFrame::OnQuit)
END_EVENT_TABLE ()
void MyFrame::OnAbout(wxCommandEvent & event)
{
wxString msg;
msg.Printf(wxT(" Hello and welcome to %s"), wxVERSION_STRING);
wxMessageBox(msg,wxT ("About Minimal"),wxOK | wxICON_INFORMATION,this);
}
void MyFrame::OnQuit(wxCommandEvent & event)
{
// 释放主窗口
Close ();
}
MyFrame::MyFrame(const wxString & title ):wxFrame(NULL,wxID_ANY,title)
{
// 设置窗口图标
SetIcon(wxIcon(mondrian_xpm));
// 创建菜单条
wxMenu *fileMenu = new wxMenu ;
// 添加“关于”菜单项
wxMenu *helpMenu = new wxMenu ;
helpMenu->Append(wxID_ABOUT,wxT("& About ...\ tF1"), wxT("Show about dialog" ));
fileMenu->Append ( wxID_EXIT , wxT ("E& xit\tAlt−X"),wxT(" Quit this program "));
// 将菜单项添加到菜单条中
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append( fileMenu,wxT("& File"));
menuBar->Append( helpMenu,wxT ("& Help"));
// 然后将菜单条放置在主窗口上...
SetMenuBar(menuBar);
// 创建一个状态条来让一切更有趣些。
CreateStatusBar(2);
SetStatusText(wxT (" Welcome to wxWidgets !"));
}
报错如下:
mple.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall wxObject::Ref(class wxObject const &)" (?Ref@wxObject@@QAEXABV1@@Z),该符号在函数 "public: class wxObject & __thiscall wxObject::operator=(class wxObject const &)" (??4wxObject@@QAEAAV0@ABV0@@Z) 中被引用
1>simple.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall wxWindowBase::SetInitialSize(class wxSize const &)" (?SetInitialSize@wxWindowBase@@QAEXABVwxSize@@@Z),该符号在函数 "protected: virtual void __thiscall wxWindowBase::SetInitialBestSize(class wxSize const &)" (?SetInitialBestSize@wxWindowBase@@MAEXABVwxSize@@@Z) 中被引用
1>simple.obj : error LNK2019: 无法解析的外部符号 "class wxWindow * __cdecl wxGetTopLevelParent(class wxWindow *)" (?wxGetTopLevelParent@@YAPAVwxWindow@@PAV1@@Z),该符号在函数 "public: virtual bool __thiscall wxTopLevelWindowBase::IsActive(void)" (?IsActive@wxTopLevelWindowBase@@UAE_NXZ) 中被引用
1>simple.obj : error LNK2019: 无法解析的外部符号 "public: static class wxWindow * __cdecl wxWindowBase::FindFocus(void)" (?FindFocus@wxWindowBase@@SAPAVwxWindow@@XZ),该符号在函数 "public: virtual bool __thiscall wxTopLevelWindowBase::IsActive(void)" (?IsActive@wxTopLevelWindowBase@@UAE_NXZ) 中被引用
1>simple.obj : error LNK2019: 无法解析的外部符号 "public: virtual __thiscall wxFrameBase::~wxFrameBase(void)" (??1wxFrameBase@@UAE@XZ),该符号在函数 __unwindfunclet$??0wxFrame@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J1@Z$0 中被引用
1>simple.obj : error LNK2019: 无法解析的外部符号 "public: bool __thiscall wxFrame::Create(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long,class wxString const &)" (?Create@wxFrame@@QAE_NPAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J1@Z),该符号在函数 "public: __thiscall wxFrame::wxFrame(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long,class wxString const &)" (??0wxFrame@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J1@Z) 中被引用
1>simple.obj : error LNK2019: 无法解析的外部符号 "protected: void __thiscall wxFrame::Init(void)" (?Init@wxFrame@@IAEXXZ),该符号在函数 "public: __thiscall wxFrame::wxFrame(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long,class wxString const &)" (??0wxFrame@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J1@Z) 中被引用
1>simple.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall wxFrameBase::wxFrameBase(void)" (??0wxFrameBase@@QAE@XZ),该符号在函数 "public: __thiscall wxFrame::wxFrame(class wxWindow *,int,class wxString const &,class wxPoint const &,class wxSize const &,long,class wxString const &)" (??0wxFrame@@QAE@PAVwxWindow@@HABVwxString@@ABVwxPoint@@ABVwxSize@@J1@Z) 中被引用
1>simple.obj : error LNK2001: 无法解析的外部符号 "protected: virtual struct wxEventTable const * __thiscall wxFrame::GetEventTable(void)const " (?GetEventTable@wxFrame@@MBEPBUwxEventTable@@XZ)
1>simple.obj : error LNK2001: 无法解析的外部符号 "protected: virtual class wxEventHashTable & __thiscall wxFrame::GetEventHashTable(void)const " (?GetEventHashTable@wxFrame@@MBEAAVwxEventHashTable@@XZ)
1>simple.obj : error LNK2019: 无法解析的外部符号 "protected: bool __thiscall wxFrame::MSWDoTranslateMessage(class wxFrame *,struct tagMSG *)" (?MSWDoTranslateMessage@wxFrame@@IAE_NPAV1@PAUtagMSG@@@Z),该符号在函数 "public: virtual bool __thiscall wxFrame::MSWTranslateMessage(struct tagMSG *)" (?MSWTranslateMessage@wxFrame@@UAE_NPAUtagMSG@@@Z) 中被引用
1>simple.obj : error LNK2019: 无法解析的外部符号 "public: static class wxMenuItem * __cdecl wxMenuItemBase::New(class wxMenu *,int,class wxString const &,class wxString const &,enum wxItemKind,class wxMenu *)" (?New@wxMenuItemBase@@SAPAVwxMenuItem@@PAVwxMenu@@HABVwxString@@1W4wxItemKind@@0@Z),该符号在函数 "public: class wxMenuItem * __thiscall wxMenuBase::Append(int,class wxString const &,class wxString const &,enum wxItemKind)" (?Append@wxMenuBase@@QAEPAVwxMenuItem@@HABVwxString@@0W4wxItemKind@@@Z) 中被引用
1>simple.obj : error LNK2019: 无法解析的外部符号 "public: virtual __thiscall wxMenuBase::~wxMenuBase(void)" (??1wxMenuBase@@UAE@XZ),该符号在函数 __unwindfunclet$??0wxMenu@@QAE@J@Z$0 中被引用
1>simple.obj : error LNK2019: 无法解析的外部符号 "private: void __thiscall wxMenu::Init(void)" (?Init@wxMenu@@AAEXXZ),该符号在函数 "public: __thiscall wxMenu::wxMenu(long)" (??0wxMenu@@QAE@J@Z) 中被引用
1>simple.obj : error LNK2001: 无法解析的外部符号 "public: virtual class wxClassInfo * __thiscall wxMenu::GetClassInfo(void)const " (?GetClassInfo@wxMenu@@UBEPAVwxClassInfo@@XZ)
1>simple.obj : error LNK2001: 无法解析的外部符号 "protected: virtual struct wxEventTable const * __thiscall wxEvtHandler::GetEventTable(void)const " (?GetEventTable@wxEvtHandler@@MBEPBUwxEventTable@@XZ)
1>simple.obj : error LNK2001: 无法解析的外部符号 "protected: virtual class wxEventHashTable & __thiscall wxEvtHandler::GetEventHashTable(void)const " (?GetEventHashTable@wxEvtHandler@@MBEAAVwxEventHashTable@@XZ)
1>simple.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall wxMenu::Break(void)" (?Break@wxMenu@@UAEXXZ)
1>simple.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __thiscall wxMenuBase::FindItem(class wxString const &)const " (?FindItem@wxMenuBase@@UBEHABVwxString@@@Z)
1>simple.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall wxMenuBase::SetHelpString(int,class wxString const &)" (?SetHelpString@wxMenuBase@@UAEXHABVwxString@@@Z)
1>simple.obj : error LNK2001: 无法解析的外部符号 "public: virtual class wxString __thiscall wxMenuBase::GetHelpString(int)const " (?GetHelpString@wxMenuBase@@UBE?AVwxString@@H@Z)
1>simple.obj : error LNK2001: 无法解析的外部符号 "public: virtual void __thiscall wxMenu::SetTitle(class wxString const &)" (?SetTitle@wxMenu@@UAEXABVwxString@@@Z)