01 - 编译链接第一个wxWidgets3.0例子

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源代码

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

 

 

第一个程序很简单,应该不会出什么错误.

转载于:https://www.cnblogs.com/xzpp/p/3590541.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值