一直想学习wxWidgets,之前使用的都是wxPython,现在终于鼓起勇气学习这个了,发现原来是基于vc6.0开发的。所以最好的学习办法就是安装vistual studio 2010,方便学习看代码。wxWidgets里面也有demo。
Similarity to MFC
MFC and wxWidgets macros
MFC version | wxWidgets version |
---|---|
BEGIN_MESSAGE_MAP |
BEGIN_EVENT_TABLE |
END_MESSAGE_MAP |
END_EVENT_TABLE |
DECLARE_DYNAMIC |
DECLARE_CLASS |
DECLARE_DYNCREATE |
DECLARE_DYMAMIC_CLASS |
IMPLEMENT_DYNAMIC |
IMPLEMENT_CLASS |
IMPLEMENT_DYNCREATE |
IMPLEMENT_DYNAMIC_CLASS |
IsKindOf (RUNTIME_CLASS (CWindow)) |
IsKindOf (CLASSINFO(wxWindow)) |
MFC and wxWidgets classes
Miscellaneous Classes | |
MFC version | wxWidgets version |
---|---|
CWinApp |
wxApp |
CObject |
wxObject |
CCmdTarget |
wxEvtHandler |
CCommandLineInfo |
wxCmdLineParser |
CMenu |
wxMenu, wMenuBar, wxMenuItem |
CWaitCursor |
wxBusyCursor |
CDataExchange |
wxValidator |
Window Classes | |
MFC version | wxWidgets version |
CFrameWnd |
wxFrame |
CMDIFrameWnd |
wxMDIParentFrame |
CMDIChildWnd |
wxMDIChildFrame |
CSplitterWnd |
wxSplitterWindow |
CToolBar |
wxToolBar |
CStatusBar |
wxStatusBar |
CReBar |
wxCoolBar, but see contrib/src/fl and wxAUI, wxDockIt |
CPropertyPage |
wxPanel |
CPropertySheet |
wxNotebook, wxPropertySheetDialog |
Dialog Classes | |
MFC version | wxWidgets version |
CDialog |
wxDialog |
CColorDialog |
wxColourDialog |
CFileDialog |
wxFileDialog |
CFindReplaceDialog |
wxFindReplaceDialog |
CFontDialog |
wxFontDialog |
CPageSetupDialog |
wxPageSetupDialog |
CPrintDialog |
wxPrintDialog |
Control Classes | |
MFC version | wxWidgets version |
CAnimateCtrl |
wxMediaCtrl, wxAnimationCtrl |
CButton |
wxButton |
CBitmapButton |
wxBitmapButton |
CComboBox |
wxComboBox, wxChoice |
CDateTimeCtrl |
wxDatePickerCtrl |
CEdit |
wxTextCtrl |
CHotKeyCtrl |
None, but see Keybinder |
CListBox , CDragListBox |
wxListBox |
CCheckListBox |
wxCheckListBox |
CListCtrl |
wxListCtrl, wxListView |
CMonthCalCtrl |
wxCalendarCtrl |
CProgressCtrl |
wxGauge |
CReBarCtrl |
None, but see contrib/src/fl and wxAUI, wxDockIt |
CRichEditCtrl |
wxTextCtrl |
CScrollBar |
wxScrollBar |
CSliderCtrl |
wxSlider |
CSpinButtonCtrl |
wxSpinButton, wxSpinCtrl |
CStatic |
wxStaticText, wxStaticLine, wxStaticBox, wxStaticBitmap |
CStatusBarCtrl |
wxStatusBar |
CTabCtrl |
wxTabCtrl |
CToolBarCtrl |
wxToolBar |
CToolTipCtrl |
wxToolTip |
CTreeCtrl |
wxTreeCtrl |
Graphics Classes | |
MFC version | wxWidgets version |
CBitmap |
wxBitmap, wxImage, wxIcon, wxCursor |
CBrush |
wxBrush |
CPen |
wxPen |
CFont |
wxFont |
CImageList |
wxImageList, wxIconBundle |
CPalette |
wxPalette |
CRgn |
wxRegion |
CClientDC |
wxClientDC |
CMetaFileDC |
wxMetaFileDC |
CPaintDC |
wxPaintDC |
CWindowDC |
wxWindowDC |
CDC |
wxDC, wxMemoryDC |
Data Structure Classes | |
MFC version | wxWidgets version |
CArray , CObArray , CPtrArray |
wxArray |
CStringArray |
wxArrayString |
CDWordArray , CByteArray , CUIntArray |
wxArrayInt |
CList , CPtrList , CObList |
wxList |
CStringList |
wxArrayString, wxStringList |
CMap |
wxHashMap |
CString |
wxString |
CPoint |
wxPoint |
CRect |
wxRect |
CSize |
wxSize |
CTime |
wxDateTime |
CTimeSpan |
wxTimeSpan, wxDateSpan |
COleVariant |
wxVariant |
Internet Classes | |
MFC version | wxWidgets version |
CSocket |
wxSocket |
CFtpConnection |
wxFTP |
CHttpConnection |
wxHTTP |
Document/View Classes | |
MFC version | wxWidgets version |
CDocument |
wxDocument |
CView |
wxView |
CDocTemplate , CSingleDocTemplate , CMultiDocTemplate |
wxDocTemplate |
Drag and Drop Classes | |
MFC version | wxWidgets version |
COleDataSource |
wxDataObject |
COleDropSource |
wxDropSource |
COleDropTarget |
wxDropTarget |
File Classes | |
MFC version | wxWidgets version |
CFile |
wxFile, wxFFile, wxTextFile |
CMemFile |
wxMemoryInputStream, wxMemoryOutputStream |
CSocketFile |
wxSocketInputStream, wxSocketOutputStream |
CRecentFileList |
wxFileHistory |
Multithreading Classes | |
MFC version | wxWidgets version |
CWinThread |
wxThread |
CCriticalSection |
wxCriticalSection |
CMutex |
wxMutex |
CSemaphore |
wxSemaphore |
![](http://img.e-com-net.com/image/info8/2f4be79989bb4905bfbfdf2cb10b8c06.jpg)
1,下载
下载安装文件
http://sourceforge.net/projects/wxwindows/files/
安装文件:
wxWidgets-2.8.12(特别注意下不要使用开发版本,要使用稳定版本)
2,开发环境使用 visual studio 2010
安装IDE参考:
http://blog.csdn.net/freewebsys/article/details/12028265
3,安装wxwdiget(基于源码编译安装)
下载zip文件
打开工程D:/wxWidgets-2.8.12/build/msw/wx.dsw
可以使用exe安装,(相当于解压缩源代码,不是安装)也可以使用zip解压缩,两个都是将源代码放到一个目录,没有啥区别。
然后编译,否则不能使用!!!!!!
wxWidgets使用的是vc6.0开发的,需要转换成vistual studio 2010。(IDE会自动转换的,耐心等待)
转换完成之后直接build就行了。
编译完成没有任何错误信息。说明安装成功。
4,编译demo
在安装后的wxWidgets-2.9.5/samples目录下面有samples.dsw
双击就可以启动visual studio了,同样需要转换成工程。
继续等待。转换完成之后就可以编译了。
里面的demo都可以编译成功,运行如下:
转换完成之后就可以进行编译了。发现编译有4个失败的。不过没有关系大多数成功了。
运行一个demo:
丰富的demo找了几个运行下效果如下:
一个简单的播放器
一个所有组件的demo。比较全。
5,WxWidgets的一个helloworld
/*
* hworld.cpp
* Hello world sample by Robert Roebling
*/
#include "wx/wx.h"
class MyApp: public wxApp
{
virtual bool OnInit();
};
class MyFrame: public wxFrame
{
public:
MyFrame(const wxString& title,
const wxPoint& pos, const wxSize& size);
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
};
enum
{
ID_Quit = 1,
ID_About,
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_Quit, MyFrame::OnQuit)
EVT_MENU(ID_About, MyFrame::OnAbout)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
MyFrame *frame = new MyFrame( "Hello World",
wxPoint(50,50), wxSize(450,340) );
frame->Show(TRUE);
SetTopWindow(frame);
return TRUE;
}
MyFrame::MyFrame(const wxString& title,
const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
wxMenu *menuFile = new wxMenu;
menuFile->Append( ID_About, "&About..." );
menuFile->AppendSeparator();
menuFile->Append( ID_Quit, "E&xit" );
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append( menuFile, "&File" );
SetMenuBar( menuBar );
CreateStatusBar();
SetStatusText( "Welcome to wxWindows!" );
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox("This is a wxWindows Hello world sample",
"About Hello World", wxOK | wxICON_INFORMATION, this);
}
![](http://img.e-com-net.com/image/info8/d4db23f2fbbe4141aba1da9dd493b929.jpg)
其他的继续研究。。。
其他参考:
http://www.cnzui.com/archives/962
http://blog.csdn.net/chinabinlang/article/details/6904143
http://www.codeproject.com/Articles/11515/Introduction-to-wxWidgets