01 - 编译链接第一个wxWidgets3.0例子
2014-03-09 20:17
309 查看
1. preprocessor
#define __WXMSW__
#define WXUSINGDLL
2. vc10中设置Include dir, lib dir, dll path
VC++平台编译完的lib 和DLL都在这个目录下 C:\Programs\wxWidgets-3.0.0\lib\vc_dll
3. HelloWorld源代码
第一个程序很简单,应该不会出什么错误.
#define __WXMSW__
#define WXUSINGDLL
2. vc10中设置Include dir, lib dir, dll path
VC++平台编译完的lib 和DLL都在这个目录下 C:\Programs\wxWidgets-3.0.0\lib\vc_dll
3. HelloWorld源代码
// wxWidgets "Hello world" Program // For compilers that support precompilation, includes "wx/wx.h". #define __WXMSW__ #define WXUSINGDLL #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); private: void OnHello(wxCommandEvent& event); void OnExit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); wxDECLARE_EVENT_TABLE(); }; enum { ID_Hello = 1 }; wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_Hello, MyFrame::OnHello) EVT_MENU(wxID_EXIT, MyFrame::OnExit) EVT_MENU(wxID_ABOUT, MyFrame::OnAbout) wxEND_EVENT_TABLE() wxIMPLEMENT_APP(MyApp); bool MyApp::OnInit() { MyFrame *frame = new MyFrame( "Hello World", wxPoint(50, 50), wxSize(450, 340) ); frame->Show( true ); return true; } MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame(NULL, wxID_ANY, title, pos, size) { wxMenu *menuFile = new wxMenu; menuFile->Append(ID_Hello, "&Hello...\tCtrl-H", "Help string shown in status bar for this menu item"); menuFile->AppendSeparator(); menuFile->Append(wxID_EXIT); wxMenu *menuHelp = new wxMenu; menuHelp->Append(wxID_ABOUT); wxMenuBar *menuBar = new wxMenuBar; menuBar->Append( menuFile, "&File" ); menuBar->Append( menuHelp, "&Help" ); SetMenuBar( menuBar ); CreateStatusBar(); SetStatusText( "Welcome to wxWidgets!" ); } void MyFrame::OnExit(wxCommandEvent& event) { Close( true ); } void MyFrame::OnAbout(wxCommandEvent& event) { wxMessageBox( "This is a wxWidgets' Hello world sample", "About Hello World", wxOK | wxICON_INFORMATION ); } void MyFrame::OnHello(wxCommandEvent& event) { wxLogMessage("Hello world from wxWidgets!"); }
第一个程序很简单,应该不会出什么错误.
相关文章推荐
- AOJ 0033 深度优先搜索
- C# 串口操作系列(3) -- 协议篇,二进制协议数据解析
- hdu 4762 Cut the Cake(推导+高精度)
- eclipse常用快捷键
- AJAX
- 路由器重围特权密码
- Java界面SWT基本组件——Button
- 120、php中foreach()用法
- PhoneGap3.3 安卓环境配置
- 一些关于jdbc的小知识点
- 国内国外CMS内容管理讨论
- 图灵完备
- 1190: [HNOI2007]梦幻岛宝珠 - BZOJ
- 入手FUJIFILM X100S
- 2014年2月总结
- Android菜鸟的成长笔记(15)—— Android中的状态保存探究(下)
- Json数据异步绑定到界面的Table并且自动刷新
- A题笔记(13)
- 丁石孙
- 加密、解密、openssl的基本应用及CA的实现过程