初用wxWidgets 2.9.4(手机播放器连载系列1)
1、下载源代码:http://www.wxwidgets.org/,下载目前最新的版本
wxWidgets 2.9.4 Released
2012-07-09
HTML: ZIP or tar.bz2===============任意一个版本
2、使用nmake编译
先修改,因为我想要unicode debug版本,修改wxWidgets-2.9.4\build\msw\config.vc
# What type of library to build? [0,1]=============生成类型库,0为静态库,1为动态库
SHARED = 0
# Compile Unicode build of wxWidgets? [0,1]=======是否使用UNICODE,0否,1是
UNICODE = 1
# Type of compiled binaries [debug,release]=========是debug还是release
BUILD = debug
也可以在编译的时候加上:
nmake -f makefile.vc SHARED=1 UNICODE=1 BUILD=release
启动nmake进入目录E:\wxWidgets-2.9.4\build\msw
nmake -f makefile.vc
得到编译后的lib,来个测试项目
先来配置一下工程:
a.工程---------------配置属性------------------C/C++-----------------常规----------------附加包含目录--------------------------E:\wxWidgets-2.9.4\include;E:\wxWidgets-2.9.4\include\msvc;
b.工程---配置属性----链接器-----附加库目录--------------------E:\wxWidgets-2.9.4\lib\vc_lib
c.工程---配置属性----链接器-----输入-----------加入以下:
wxmsw29ud_core.lib
wxbase29ud.lib
wxtiffd.lib
wxjpegd.lib
wxpngd.lib
wxzlibd.lib
wxregexud.lib
wxexpatd.lib
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib
odbc32.lib
3、
引用这位大哥的一个demo(带有main的,多幸福!)
http://www.cnblogs.com/godspeedsam/archive/2010/12/24/1915858.html
useWxWidgets.cpp:(控制台的)
// useWxWidgets.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <wx/wx.h> #include "client.h" int main(int argc,char* argv[]) { MyApp* app=new MyApp(); wxApp::SetInstance(app); return wxEntry(argc,argv); }
client.h:
#include <wx/wx.h> class MyFrame : public wxFrame { public: MyFrame() ; }; class MyApp: public wxApp { wxFrame* m_frame; public: bool OnInit(); };
client.cpp:
#include "stdafx.h"#include <wx/wx.h> #include "client.h"MyFrame:: MyFrame() : wxFrame(NULL, wxID_ANY, wxT("Hello wxWidgets"), wxPoint(50,50), wxSize(800,600)) { wxPanel* mainPane = new wxPanel(this); wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); // add widgets here! mainPane->SetSizer(sizer); } bool MyApp::OnInit() { m_frame = new MyFrame(); m_frame->Show(); return true; }
WinMain的:
#include "stdafx.h"#include <wx/wx.h> #include "client.h"#include "windows.h"int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow){MyApp* app=new MyApp(); wxApp::SetInstance(app); return wxEntry(hInstance,hPrevInstance); }