wxwidgetstudy/src/window_sign.cpp

46 lines
1.3 KiB
C++
Raw Normal View History

2024-01-25 14:52:04 +08:00
#include "window_sign.h"
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
END_EVENT_TABLE()
bool MyApp::OnInit()
{
MyFrame* frame = new MyFrame(wxT("Minimal wxWidgets App"));
frame->Show(true);
return true;
}
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!"));
}