#include "wx/wx.h" 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() }; DECLARE_APP(MyApp) IMPLIMENT_APP(MyApp) bool MyApp::OnInit()//the proplem in here, after it complied that result is: //error: expected constructor, destructor, //or type conversion before "bool" { MyFrame *frame = new MyFrame(wxT("Minimal wxWidget App")); frame->Show(true); return true; } 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(); } #include "mondrian.xpm" 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 dailog")); 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!")); }
Louis Cooper wrote:IMPLIMENT_APP(MyApp)
IMPLEMENT_APP(MyApp)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)