Chinaunix首页 | 论坛 | 博客
  • 博客访问: 247469
  • 博文数量: 49
  • 博客积分: 110
  • 博客等级: 民兵
  • 技术积分: 510
  • 用 户 组: 普通用户
  • 注册时间: 2013-01-13 00:59
个人简介

make it run,make it better,make it fast. https://github.com/liulanghaitun

文章分类

全部博文(49)

文章存档

2023年(1)

2022年(2)

2020年(4)

2019年(4)

2017年(15)

2016年(3)

2014年(3)

2013年(14)

分类: C/C++

2017-10-21 22:21:30

开发环境:gentoo Linux gentoo 4.12.12-gentoo
开发工具: codelite 9.1
推荐书籍:使用wxWidgets进行跨平台开发.pdf
新建工程,选择wxWidgets Console Apllication

点击(此处)折叠或打开

  1. #include <wx/wxprec.h>
  2.   
  3. #ifndef WX_PRECOMP
  4.     #include <wx/wx.h>
  5. #endif
  6.   
  7. class MyApp: public wxApp
  8. {
  9. public:
  10.     virtual bool OnInit();
  11. };
  12.   
  13. class MyFrame: public wxFrame
  14. {
  15. public:
  16.     MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
  17. private:
  18.     void OnHello(wxCommandEvent& event);
  19.     void OnExit(wxCommandEvent& event);
  20.     void OnAbout(wxCommandEvent& event);
  21.     DECLARE_EVENT_TABLE();
  22. };
  23.   
  24. enum
  25. {
  26.     ID_Hello = 1
  27. };
  28.   
  29. BEGIN_EVENT_TABLE(MyFrame, wxFrame)
  30.     EVT_MENU(ID_Hello, MyFrame::OnHello)
  31.     EVT_MENU(wxID_EXIT, MyFrame::OnExit)
  32.     EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
  33. END_EVENT_TABLE()
  34.   
  35. IMPLEMENT_APP(MyApp);
  36.   
  37. bool MyApp::OnInit()
  38. {
  39.     MyFrame *frame = new MyFrame(wxT("Hello World"), wxPoint(50, 50), wxSize(450, 340) );
  40.     frame->Show( true );
  41.     return true;
  42. }
  43.   
  44. MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame(NULL, wxID_ANY, title, pos, size)
  45. {
  46.     wxMenu *menuFile = new wxMenu;
  47.     menuFile->Append(ID_Hello, wxT("&Hello...\tCtrl-H"), wxT("Help string shown in status bar for this menu item"));
  48.     menuFile->AppendSeparator();
  49.     menuFile->Append(wxID_EXIT);
  50.     wxMenu *menuHelp = new wxMenu;
  51.     menuHelp->Append(wxID_ABOUT);
  52.     wxMenuBar *menuBar = new wxMenuBar;
  53.     menuBar->Append( menuFile, wxT("&File"));
  54.     menuBar->Append( menuHelp, wxT("&Help"));
  55.     SetMenuBar( menuBar );
  56.     CreateStatusBar();
  57.     SetStatusText(wxT("Welcome to wxWidgets!"));
  58. }
  59.   
  60. void MyFrame::OnExit(wxCommandEvent& event)
  61. {
  62.     Close( true );
  63. }
  64.   
  65. void MyFrame::OnAbout(wxCommandEvent& event)
  66. {
  67.     wxMessageBox(wxT("This is a wxWidgets' Hello world sample"),wxT("About Hello World"), wxOK | wxICON_INFORMATION );
  68. }
  69.   
  70. void MyFrame::OnHello(wxCommandEvent& event)
  71. {
  72.     wxLogMessage(wxT("Hello world from wxWidgets!"));
  73. }

阅读(901) | 评论(0) | 转发(0) |
0

上一篇:

下一篇:the little schemer(第三章)

给主人留下些什么吧!~~