一个基本的wxWidgets程序
2016-04-08 10:30
295 查看
转自Cross Platform Gui Programming
配置:win10+msvc2013+wxWidgets3.1.0
配置:win10+msvc2013+wxWidgets3.1.0
#include<wx/wx.h> class MyApp : public wxApp { public: virtual bool OnInit(); }; class MyFrame : public wxFrame { public: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); private: wxDECLARE_EVENT_TABLE(); }; //声明可以使用全局的指针MyApp& wxGetApp(); DECLARE_APP(MyApp); //事件映射表; wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(wxID_ABOUT,MyFrame::OnAbout) //菜单项关联到事件处理函数; EVT_MENU(wxID_EXIT,MyFrame::OnQuit) wxEND_EVENT_TABLE() //主程序入口; wxIMPLEMENT_APP(MyApp); //初始化定义; bool MyApp::OnInit() { //MyFrame *frame = new MyFrame("Hello World", wxPoint(50, 50), wxSize(450, 340)); MyFrame *frame = new MyFrame("Hello World", wxDefaultPosition, wxDefaultSize); frame->Show(true); return true; } MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame(NULL, wxID_ANY, title, pos, size) { //创建菜单项; wxMenu *fileMenu = new wxMenu; fileMenu->Append(wxID_ABOUT); wxMenu* helpMenu = new wxMenu; helpMenu->Append(wxID_EXIT); //创建菜单条; wxMenuBar *menuBar = new wxMenuBar; menuBar->Append(fileMenu, "&File"); menuBar->Append(helpMenu, "&Help"); SetMenuBar(menuBar); //创建状态栏; CreateStatusBar(); SetStatusText("Welcome to wxWidgets!"); } void MyFrame::OnQuit(wxCommandEvent& event) { Close(); } 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); }
相关文章推荐
- Http的常见问题
- System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest.GetResponse()
- ZooKeeper原理及使用
- 创建jason,jason转换为字符串,字符串转换回jason,c#反序列化jason字符串的几个代码片段
- Day6、Python
- windows下cmd命令行显示UTF8字符设置
- 宏定义的黑魔法 - 宏菜鸟起飞手册(喵神)
- HDU1711 KMP
- HEVC的帧内预测(2)
- Matlab PCA+SVM人脸识别(一)
- 去哪儿编程题-寻找Coder
- pat--一元多项式的乘法与加法
- elasticsearch,python包pyes进行的处理
- 5个最好用AngularJS构建应用程序框架
- 第一篇博文
- Wget用法、参数解释的比较好的一个文章
- 4月初.wang域名总量15强:盛极而衰 仅3家上涨
- nginx初步学习-配置反向代理
- ECLIPSE(JAVA, SCALA)中TAB WIDTH的设置
- 电容屏驱动技术