[base.h]
#ifndef __BASE_H
#define __BASE_H
class MainApp: public wxApp
{
public:
virtual bool OnInit();
};
class MainFrame: public wxFrame
{
public:
MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size);
void OnQuit(wxCommandEvent &event);
void OnAbout(wxCommandEvent &event);
private:
DECLARE_EVENT_TABLE()
};
enum
{
ID_MAINWIN_QUIT = wxID_HIGHEST+1,
ID_MAINWIN_ABOUT = wxID_HIGHEST+2
};
#endif
[base.cpp]
#include
#ifndef WX_PRECOMP
#include
#endif
#include "base.h"
IMPLEMENT_APP(MainApp)
bool MainApp::OnInit()
{
MainFrame *win = new MainFrame(_("Frame"), wxPoint (100, 100),
wxSize(450, 340));
win->Show(TRUE);
SetTopWindow(win);
return TRUE;
}
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
EVT_MENU(ID_MAINWIN_QUIT, MainFrame::OnQuit)
EVT_MENU(ID_MAINWIN_ABOUT,MainFrame::OnAbout)
END_EVENT_TABLE()
MainFrame::MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
: wxFrame((wxFrame *) NULL, -1, title, pos, size)
{
wxMenu *FileMenu = new wxMenu;
wxMenuBar *MenuBar = new wxMenuBar;
FileMenu->Append(ID_MAINWIN_QUIT, _("&Quit"));
FileMenu->Append(ID_MAINWIN_ABOUT,_("&About"));
MenuBar->Append(FileMenu, _("&File"));
SetMenuBar(MenuBar);
CreateStatusBar(2);
SetStatusText(_("Hello World!"));
}
void MainFrame::OnQuit(wxCommandEvent & WXUNUSED(event))
{
Close(TRUE);
}
void MainFrame::OnAbout(wxCommandEvent & WXUNUSED(event))
{
wxMessageBox(_("love make the world go around!"),_("important:"),wxOK,this);
}
阅读(2523) | 评论(1) | 转发(0) |