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 }

 

 

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