1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <wx/wx.h>
class MyApp : public wxApp
{
virtual bool OnInit();
};
IMPLEMENT_APP(MyApp)
class MyFrame : public wxMDIParentFrame
{
public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
};
enum
{
ID_Quit=1,
ID_About
};
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame("SubWindows", wxPoint(50,50),
wxSize(450,350));
frame->Connect( ID_Quit, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) &MyFrame::OnQuit );
frame->Connect( ID_About, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) &MyFrame::OnAbout );
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxMDIParentFrame((wxFrame*)NULL,-1,title,pos,size)
{
wxMenuBar *menuBar = new wxMenuBar;
wxMenu *menuFile = new wxMenu;
menuFile->Append(ID_About,"About");
menuFile->AppendSeparator();
menuFile->Append(ID_Quit,"Exit");
menuBar->Append(menuFile, "File");
SetMenuBar(menuBar);
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
wxMDIClientWindow *client = new wxMDIClientWindow(this, 0);
wxMDIChildFrame *child = new wxMDIChildFrame(this, -1, "Child", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "child");
sizer->Add(client, 1, wxEXPAND | wxALL, 0);
SetSizer(sizer);
CreateStatusBar();
SetStatusText("SubWindows");
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox("wxWindows sub windows example.","About",
wxOK|wxICON_INFORMATION, this);
} |
Partager