WXWindows Frame Program Simplified Edition
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. Double-click CMYAPP constructor cmyapp () in ClassView, add #include "wx / wx.h" in MyApp.cpp. Right-click CMYApp in ClassView, select Add Member function, joining a PUBLIC Virtual Bool OnNInit () member function .5. Modify CMYAPP's OnInit () Bool CmyApp :: OnNInit () {wxframe * frame = new wxframe (wxframe *) NULL, -1, _T ( "My First Frame Window"), wxpoint (100, 100), WXSIZE (400, 300)); // Create Status Bar Frame-> CreateStatusbar (); frame-> setStatustext (_t ("Status Bar Ready")); / / Display window frame-> show (true); settopwindow; return true;} 6. Add import_app (cmyapp) in CMYAPP: CMYAPP () {}, see below: Implement_app (cmyapp) cmyapp :: CmyApp () {} 7 This time you have a fatal error (Fatal Error) Fatal Error C1083: Cannot Open include file: 'wx / setup.h': No sudh file or directory how to solve it? Look at the bottom 8. Set good settings win32 debug Configuration C tab pre-processing defined as: _debug, win32, _windows, _mt, winver = 0x400, _wxuse_gui, __ wxdebug__, WxDebug = 1 Extra included header directory: $ (wxwin) / lib / mswd precompiled head file Select Automatic Use of Precompiled Headers Code Generation Select Debug Multithreaded DLL LINK Tab At the end of the object code module, add comctl32 .lib rpcrt4.lib wsock32.lib wxmswd.lib, these 4 library // source files Attached to //// 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 ();}; DECLARE_APP (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"
//// construction / destruction // Implement_app (cmyapp) CMYAPP :: CMYAPP () {
}
CMYAPP :: ~ CMYAPP () {
}
Bool cmyapp :: oninit () {wxframe * frame = new wxframe ((wxframe *) NULL, -1, _T ("My First Frame Window"), WXPoint (100, 100), WXSIZE (400, 300)); //// Create a status bar frame-> createstatusbar (); frame-> setStatustext (_t ("status bar ready"))); // Display window frame-> show (true); settopwindow; rRN true;}