该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
本人学的是wxWidgets,就以它为例了。
#include
#include
#include
#include
#include
#include
#include
#include
//*)
class SampleApp : public wxApp
{
public:
virtual bool OnInit();
};
IMPLEMENT_APP(SampleApp);
bool SampleApp::OnInit()
{
//(*AppInitialize
bool wxsOK = true;
wxInitAllImageHandlers();
if ( wxsOK )
{
SampleFrame* Frame = new SampleFrame(0);
Frame->Show();
SetTopWindow(Frame);
}
return wxsOK;
}
class SampleFrame: public wxFrame
{
public:
SampleFrame(wxWindow* parent,wxWindowID id = -1);
virtual ~SampleFrame();
private:
//(*Handlers(SampleFrame)
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
//*)
//(*Identifiers(SampleFrame)
static const long idMenuQuit;
static const long idMenuAbout;
static const long ID_STATUSBAR1;
//*)
//(*Declarations(SampleFrame)
wxStatusBar* StatusBar1;
//*)
DECLARE_EVENT_TABLE()
};
//(*IdInit(SampleFrame)
const long SampleFrame::idMenuQuit = wxNewId();
const long SampleFrame::idMenuAbout = wxNewId();
const long SampleFrame::ID_STATUSBAR1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(SampleFrame,wxFrame)
//(*EventTable(SampleFrame)
//*)
END_EVENT_TABLE()
SampleFrame::SampleFrame(wxWindow* parent,wxWindowID id)
{
//(*Initialize(SampleFrame)
wxMenuItem* MenuItem2;
wxMenuItem* MenuItem1;
wxMenu* Menu1;
wxMenuBar* MenuBar1;
wxMenu* Menu2;
Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
MenuBar1 = new wxMenuBar();
Menu1 = new wxMenu();
MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
Menu1->Append(MenuItem1);
MenuBar1->Append(Menu1, _("&File"));
Menu2 = new wxMenu();
MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
Menu2->Append(MenuItem2);
MenuBar1->Append(Menu2, _("Help"));
SetMenuBar(MenuBar1);
StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
int __wxStatusBarWidths_1[1] = { -1 };
int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
SetStatusBar(StatusBar1);
Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SampleFrame::OnQuit);
Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&SampleFrame::OnAbout);
//*)
}
SampleFrame::~SampleFrame()
{
//(*Destroy(SampleFrame)
//*)
}
void SampleFrame::OnQuit(wxCommandEvent& event)
{
Close();
}
void SampleFrame::OnAbout(wxCommandEvent& event)
{
wxString msg = wxT("This is a sample windows!");
wxMessageBox(msg, _("Welcome to..."));
}