WXWindows first frame program
Contact me, please send an email to huyoo353 {at} 126 {dot} COM
A few days ago, a simple Hello World program was given. Since I was studying wxwindows these days, I wrote the first Frame framework program made today and shared it.
1. New Win32 Application, the name is Frame, then select Empty Project, point finish to complete .2. Insert a class, Class Type is Generic Class, the name is CMYAPP, the DeviceD from WxApp, the category is public ( Default), pop-up dialog box point OK.3. Insert a new class CMYFRAME according to the same steps above, the base class is wxframe, the public inheritance. 4. Double-click the CMYAPP constructor cmyapp () in the classview, in myApp.cpp.cpp Add #include "wx / wx.h" 5. Add #include "wx / wx.h" in MyFrame.cpp, right-click CMYAPP, select Add member function, join a public Virtual Bool OnInit () Member function .7. Right-click CMYFRAME in ClassView, select Add member function, join a PUBLIC's MyFrame (Const WxChar * Title, int XPOS, int yPOS, int width, int ingt) constructor (no type) ) .8. Modify MyFrame (const wxchar * title, int Xpos, int ypos, int width, int.com) is as follows:
Myframe :: MyFrame (Const WxChar * Title, Int Xpos, int ypos, int width, int tent): wxframe (wxframe *) NULL, -1, TIS, WXPOINT (XPOS, YPOS), WXSIZE (Width, HEIGHT)) {// Create status bar createstatusbar (); setStatustext ("Status Bar Ready");} 9. Modify CMYApp :: OnNit () {myframe * frame = new myframe ("My first Frame window ", 100, 100, 400, 300); frame-> show (true); return true;} 10. Add import_app (cmyapp) in the MyApp.cpp header to CMYApp: CmyApp () {}, Look below: Implement_app (cmyapp) CMYAPP :: CMYAPP () {
} 10.5 This time you have a fatal error (Fatal Error) Fatal Error C1083: Cannot Open include File: 'wx / setup.h': No Such File or Directory solves? Look at below 11. Set Good settingswin32 debug Configuration C tab pre-processing definition as: _debug, win32, _windows, _mt, winver = 0x400, _wxuse_gui, __ wxdebug __, wxdebug = 1 additional header file directory is: $ (wxwin) / lib / mswd pre-compiled head file Select the USE Runtime Library in Automatic Use of Precompiled Headerscode Generation Select the Debug Multithreaded Dllink tab in the object code module, add comctl32.lib rpcrt4.lib wsock32.lib wxmswd.lib, these 4 libraries
Compile completion, the executor is as follows:
// source file attached to the back //// MyApp.h:! Interface for the CMyApp class.////#if defined (AFX_MYAPP_H__08DC4B2E_BCC2_48EC_A02A_D82513125055__INCLUDED _) # define AFX_MYAPP_H__08DC4B2E_BCC2_48EC_A02A_D82513125055__INCLUDED_
#if _MSC_VER> 1000 # prgma overce # endif //_MSC_VER> 1000
Class CmyApp: public wxapp {public: Virtual Bool OnInit (); cmyapp (); virtual ~ cmyapp ();
}
#ENDIF /! Defined (AFX_MYAPP_H__08DC4B2E_BCC2_48EC_A02A_D82513125055__INCLUDED _) / / --------------------------------------- ---------------------------------- // myapp.cpp: Implementation of the cmyapp class.//// #include "wx / wx.h" #include "myapp.h" #include "myframe.h"
//// construction / destruction // Implement_app (cmyapp) CMYAPP :: CMYAPP () {
}
CMYAPP :: ~ CMYAPP () {
}
Bool cmyapp :: oninit () {myframe * frame = new myframe ("My First Frame Window", 100, 100, 400, 300); Frame-> Show (TRUE); return true;} // ======== ============================================= // myframe.h: interface for the myframe class.// //
#if! defined (AFX_MYFRAME_H__6DA98C02_589A_44A9_B65A_F0C1941E3AFA__INCLUDED _) # Define AFX_MYFRAME_H__6DA98C02_589A_44A9_B65A_F0C1941E3AFA__INCLUDED_
#if _MSC_VER> 1000 # prgma overce # endif //_MSC_VER> 1000
Class myframe: public wxframe {public: myframe (const wxchar * title, int xpos, int ypos, int width, int hotht);
MYFRAME (); Virtual ~ myframe ();
#ENDIF / /! Defined (AFX_MYFRAME_H__6DA98C02_589A_44A9_B65A_F0C1941E3AFA__INCLUDED _) // --------------------------------------- -------------- // myframe.cpp: Implementation of the myframe class.////include "wx / wx.h" #include "myframe.h" ///////// Construction / destruction ///////
Myframe :: myframe () {
}
Myframe :: ~ myframe () {
}
Myframe :: MyFrame (Const WxChar * Title, Int Xpos, int ypos, int width, int tent): wxframe (wxframe *) NULL, -1, TIS, WXPOINT (XPOS, YPOS), WXSIZE (Width, Height)) {// Create a status bar createsTatusbar (); setStatustext ("Status Bar Ready");} // ============================== =====================