├── .gitignore ├── 03-feelling-1 ├── 3.1.2-HelloWorld │ ├── HelloWorld.cbp │ └── main.cpp ├── 3.10.0-HelloOOVirtual │ ├── HelloOOVirtual.cbp │ └── main.cpp ├── 3.10.1-HelloOOVirtual │ ├── HelloOOVirtual.cbp │ └── main.cpp ├── 3.10.2-1-HelloOOVirtual │ ├── HelloOOVirtual.cbp │ └── main.cpp ├── 3.10.2-2-HelloOOVirtual │ ├── HelloOOVirtual.cbp │ └── main.cpp ├── 3.10.3-HelloOOVirtual │ ├── HelloOOVirtual.cbp │ └── main.cpp ├── 3.11.5-1-HelloOOEncapsulation │ ├── HelloOOEncapsulation.cbp │ └── main.cpp ├── 3.11.5-2-HelloOOEncapsulation │ ├── HelloOOEncapsulation.cbp │ └── main.cpp ├── 3.11.5-3-HelloOOEncapsulation │ ├── HelloOOEncapsulation.cbp │ └── main.cpp ├── 3.11.6-HelloOOEncapsulation │ ├── HelloOOEncapsulation.cbp │ └── main.cpp ├── 3.12.4-HelloSTLVector │ ├── HelloSTLVector.cbp │ └── main.cpp ├── 3.13.6-HelloSTLList │ ├── HelloSTLList.cbp │ └── main.cpp ├── 3.13.7-HelloSTL_ScoreManage │ ├── HelloSTL_ScoreManage.cbp │ └── main.cpp ├── 3.14.2-HelloSTL_ScoreManageVer1_01 │ ├── HelloSTL_ScoreManageVer1.01.cbp │ └── main.cpp ├── 3.14.3-HelloSTL_ScoreManageVer1_01 │ ├── HelloSTL_ScoreManageVer1.01.cbp │ └── main.cpp ├── 3.14.4-HelloSTL_ScoreManageVer1_02 │ ├── HelloSTL_ScoreManageVer1_02.cbp │ └── main.cpp ├── 3.14.6-HelloSTL_ScoreManageVer2 │ ├── HelloSTL_ScoreManageVer2.cbp │ └── main.cpp ├── 3.15.3-HelloFileStream │ ├── HelloFileStream.cbp │ └── main.cpp ├── 3.15.4-HelloSTL_ScoreManage_Ver3 │ ├── HelloSTL_ScoreManage_Ver3.cbp │ └── main.cpp ├── 3.2.2-HelloWorldCn │ ├── HelloWorldCn.cbp │ └── main.cpp ├── 3.3.3-HelloWorldFn │ ├── HelloWorldFn.cbp │ └── main.cpp ├── 3.3.4-HelloWorldFn │ ├── HelloWorldFn.cbp │ └── main.cpp ├── 3.4.4-HelloWorldInteractive │ ├── HelloWorldInteractive.cbp │ └── main.cpp ├── 3.4.5-HelloWorldInteractive │ ├── HelloWorldInteractive.cbp │ └── main.cpp ├── 3.5.2-HelloWorldIfElse │ ├── HelloWorldIfElse.cbp │ └── main.cpp ├── 3.5.3-HelloWorldIfElse │ ├── HelloWorldIfElse.cbp │ └── main.cpp ├── 3.6.2-HelloWorldWhile │ ├── HelloWorldWhile.cbp │ └── main.cpp ├── 3.7.2-HelloOO │ ├── HelloOO.cbp │ └── main.cpp ├── 3.7.3-HelloOO │ ├── HelloOO.cbp │ └── main.cpp ├── 3.7.4-HelloOO │ ├── HelloOO.cbp │ └── main.cpp ├── 3.7.5-1-HelloOO │ ├── HelloOO.cbp │ └── main.cpp ├── 3.7.5-2-HelloOO │ ├── HelloOO.cbp │ └── main.cpp ├── 3.7.5-3-HelloOO │ ├── HelloOO.cbp │ └── main.cpp ├── 3.7.5-4-HelloOO │ ├── HelloOO.cbp │ └── main.cpp ├── 3.7.7-1-HelloOO │ ├── HelloOO.cbp │ └── main.cpp ├── 3.7.7-2-HelloOO │ ├── HelloOO.cbp │ └── main.cpp ├── 3.7.7-3-HelloOO │ ├── HelloOO.cbp │ └── main.cpp ├── 3.8.0-HelloOOMember │ ├── HelloOOMember.cbp │ └── main.cpp ├── 3.8.1-1-HelloOOMember │ ├── HelloOOMember.cbp │ └── main.cpp ├── 3.8.1-2-HelloOOMember │ ├── HelloOOMember.cbp │ └── main.cpp ├── 3.8.2-HelloOOMember │ ├── HelloOOMember.cbp │ └── main.cpp ├── 3.9.1-HelloOODerive │ ├── HelloOODerive.cbp │ └── main.cpp ├── 3.9.5-HelloOODerive │ ├── HelloOODerive.cbp │ └── main.cpp ├── 3.9.6-HelloOODerive │ ├── HelloOODerive.cbp │ └── main.cpp └── 3.9.7-HelloDerive_BBS │ ├── HelloDerive_BBS.cbp │ └── main.cpp ├── 04-feeling-2 ├── 4.1-HelloGUI │ ├── HelloGUI.cbp │ ├── HelloGUIApp.h │ ├── HelloGUIMain.cpp │ ├── HelloGUIMain.h │ ├── helloguiApp.cpp │ ├── obj │ │ ├── Debug │ │ │ └── resource.res │ │ └── Release │ │ │ └── resource.res │ ├── resource.rc │ └── wxsmith │ │ ├── HelloGUIdialog.wxs │ │ └── HelloGUIframe.wxs ├── 4.2-HelloGUILayout │ ├── HelloGUILayout.cbp │ ├── HelloGUILayout.cscope_file_list │ ├── HelloGUILayoutApp.cpp │ ├── HelloGUILayoutApp.h │ ├── HelloGUILayoutMain.cpp │ ├── HelloGUILayoutMain.h │ ├── obj │ │ ├── Debug │ │ │ └── resource.res │ │ └── Release │ │ │ └── resource.res │ ├── resource.rc │ └── wxsmith │ │ └── HelloGUILayoutdialog.wxs ├── 4.3-HelloInternet │ ├── HelloInternet.cbp │ ├── HelloInternetApp.cpp │ ├── HelloInternetApp.h │ ├── HelloInternetMain.cpp │ ├── HelloInternetMain.h │ ├── aaa.txt │ ├── obj │ │ ├── Debug │ │ │ └── resource.res │ │ └── Release │ │ │ └── resource.res │ ├── resource.rc │ └── wxsmith │ │ └── HelloInternetdialog.wxs └── 4.4-HelloDatabase_Console │ ├── HelloDatabase_Console.cbp │ ├── backup_d2school_champions_2008.7z │ ├── backup_d2school_champions_2008.sql │ └── main.cpp ├── 05-base ├── 5.10-FloatPointNumberDemo1 │ ├── FloatPointNumberDemo1.cbp │ └── main.cpp ├── 5.2-BuildDemo │ ├── a.cpp │ └── b.cpp ├── 5.3-IncludeDemo1 │ ├── IncludeDemo1.cbp │ ├── main.cpp │ ├── my_file.cpp │ ├── my_file.hpp │ └── my_file2.cpp ├── 5.4-MemoryAllocTest │ ├── MemoryAllocTest.cbp │ └── main.cpp ├── 5.5-1-GlobalVarTest │ ├── GlobalVarTest.cbp │ └── main.cpp ├── 5.5-2-StackVarTest │ ├── StackVarTest.cbp │ └── main.cpp ├── 5.8-1-VarDemo1 │ ├── VarDemo1.cbp │ └── main.cpp ├── 5.8-2-PtrVarDemo1 │ ├── PtrVarDemo1.cbp │ └── main.cpp └── 5.8-3-ArrayVarDemo1 │ ├── ArrayVarDemo1.cbp │ ├── main.cpp │ └── main2.cpp ├── 06-ide ├── 6.10-WorkspaceDemo │ ├── AppDemo │ │ ├── AppDemo.cbp │ │ ├── a.txt │ │ └── main.cpp │ ├── ShareLibDemo │ │ ├── ShareLibDemo.cbp │ │ ├── bin │ │ │ └── Debug │ │ │ │ └── libShareLibDemo.def │ │ └── main.cpp │ ├── StaticLibDemo │ │ ├── StaticLibDemo.cbp │ │ └── main.cpp │ └── WorkspaceDemo.workspace ├── 6.2-header_fixup │ ├── header_fixup.cbp │ └── main.cpp └── 6.8-ProjectSettingDemo │ ├── ProjectSettingDemo.cbp │ ├── ProjectSettingDemoApp.cpp │ ├── ProjectSettingDemoApp.h │ ├── ProjectSettingDemoMain.cpp │ ├── ProjectSettingDemoMain.h │ ├── lib_finder.script │ ├── obj │ └── Debug │ │ └── resource.res │ ├── resource.rc │ └── wxsmith │ └── ProjectSettingDemodialog.wxs ├── 10-stl_and_boost ├── 10.1.1-OutputDebugInfo │ ├── OutputDebugInfo.cbp │ └── main.cpp ├── 10.1.2-SyncCppAndCStdIO │ ├── 01-SyncInput │ │ ├── SyncInput.cbp │ │ └── main.cpp │ ├── 02-SyncOutput │ │ ├── SyncOutput.cbp │ │ └── main.cpp │ ├── 03-PerformancePK │ │ ├── PerformancePK.cbp │ │ └── main.cpp │ └── SyncCppAndCStdIO.workspace └── 10.1.3-FormatIO │ ├── FormatIO.cbp │ └── main.cpp ├── 11-GUI ├── 11.1-RedX │ ├── DesktopX │ │ ├── DesktopX.cbp │ │ ├── main.cpp │ │ ├── manifest.xml │ │ ├── resource.h │ │ └── resource.rc │ └── readme.txt ├── 11.2-Win32GUI │ └── HelloWin32 │ │ ├── HelloWin32.cbp │ │ └── main.cpp ├── 11.3-wxWidgets │ ├── 11.3.2 │ │ └── HelloWxWidgets │ │ │ ├── HelloWxWidgets.cbp │ │ │ ├── HelloWxWidgetsApp.cpp │ │ │ ├── HelloWxWidgetsApp.h │ │ │ ├── HelloWxWidgetsMain.cpp │ │ │ ├── HelloWxWidgetsMain.h │ │ │ └── resource.rc │ └── 11.3.3 │ │ ├── HelloMyFrame │ │ ├── HelloMyFrame.cbp │ │ ├── HelloMyFrameApp.cpp │ │ ├── HelloMyFrameApp.h │ │ ├── HelloMyFrameMain.cpp │ │ ├── HelloMyFrameMain.h │ │ └── resource.rc │ │ └── readme.txt └── 11.4-wxFrame │ └── 11.4.1-MainMenu │ ├── HelloMenu │ ├── HelloMenu.cbp │ ├── HelloMenuApp.cpp │ ├── HelloMenuApp.h │ ├── HelloMenuMain.cpp │ ├── HelloMenuMain.h │ └── resource.rc │ ├── Ls11 │ ├── Ls11.cbp │ ├── Ls11App.cpp │ ├── Ls11App.h │ ├── Ls11Main.cpp │ ├── Ls11Main.h │ └── resource.rc │ └── readme.txt ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # CodeBlocks 35 | *.save 36 | *.html 37 | *.depend 38 | *.layout 39 | *.bmarks 40 | -------------------------------------------------------------------------------- /03-feelling-1/3.1.2-HelloWorld/HelloWorld.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.1.2-HelloWorld/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | cout << "Hello world!" << endl; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /03-feelling-1/3.10.0-HelloOOVirtual/HelloOOVirtual.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 44 | 45 | -------------------------------------------------------------------------------- /03-feelling-1/3.10.0-HelloOOVirtual/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.10.0-HelloOOVirtual/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.10.1-HelloOOVirtual/HelloOOVirtual.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 44 | 45 | -------------------------------------------------------------------------------- /03-feelling-1/3.10.1-HelloOOVirtual/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.10.1-HelloOOVirtual/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.10.2-1-HelloOOVirtual/HelloOOVirtual.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 44 | 45 | -------------------------------------------------------------------------------- /03-feelling-1/3.10.2-1-HelloOOVirtual/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.10.2-1-HelloOOVirtual/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.10.2-2-HelloOOVirtual/HelloOOVirtual.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 44 | 45 | -------------------------------------------------------------------------------- /03-feelling-1/3.10.2-2-HelloOOVirtual/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.10.2-2-HelloOOVirtual/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.10.3-HelloOOVirtual/HelloOOVirtual.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 44 | 45 | -------------------------------------------------------------------------------- /03-feelling-1/3.10.3-HelloOOVirtual/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.10.3-HelloOOVirtual/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.11.5-1-HelloOOEncapsulation/HelloOOEncapsulation.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.11.5-1-HelloOOEncapsulation/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.11.5-1-HelloOOEncapsulation/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.11.5-2-HelloOOEncapsulation/HelloOOEncapsulation.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.11.5-2-HelloOOEncapsulation/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.11.5-2-HelloOOEncapsulation/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.11.5-3-HelloOOEncapsulation/HelloOOEncapsulation.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.11.5-3-HelloOOEncapsulation/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.11.5-3-HelloOOEncapsulation/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.11.6-HelloOOEncapsulation/HelloOOEncapsulation.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.11.6-HelloOOEncapsulation/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.11.6-HelloOOEncapsulation/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.12.4-HelloSTLVector/HelloSTLVector.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.12.4-HelloSTLVector/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.12.4-HelloSTLVector/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.13.6-HelloSTLList/HelloSTLList.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.13.6-HelloSTLList/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.13.6-HelloSTLList/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.13.7-HelloSTL_ScoreManage/HelloSTL_ScoreManage.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.13.7-HelloSTL_ScoreManage/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.13.7-HelloSTL_ScoreManage/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.14.2-HelloSTL_ScoreManageVer1_01/HelloSTL_ScoreManageVer1.01.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.14.2-HelloSTL_ScoreManageVer1_01/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.14.2-HelloSTL_ScoreManageVer1_01/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.14.3-HelloSTL_ScoreManageVer1_01/HelloSTL_ScoreManageVer1.01.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.14.3-HelloSTL_ScoreManageVer1_01/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.14.3-HelloSTL_ScoreManageVer1_01/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.14.4-HelloSTL_ScoreManageVer1_02/HelloSTL_ScoreManageVer1_02.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.14.4-HelloSTL_ScoreManageVer1_02/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.14.4-HelloSTL_ScoreManageVer1_02/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.14.6-HelloSTL_ScoreManageVer2/HelloSTL_ScoreManageVer2.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.14.6-HelloSTL_ScoreManageVer2/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.14.6-HelloSTL_ScoreManageVer2/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.15.3-HelloFileStream/HelloFileStream.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.15.3-HelloFileStream/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include // 'f' -> 'file' 3 | 4 | using namespace std; 5 | 6 | istream& skip_comma ( istream& str ) 7 | { 8 | char c = str.peek(); 9 | 10 | if (c == ',') 11 | { 12 | return str.ignore(); 13 | } 14 | 15 | return str; 16 | } 17 | 18 | int main() 19 | { 20 | ofstream ofs; 21 | 22 | ofs.open("./hello_file_stream.txt"); 23 | 24 | ofs << "Hello world!" << endl; 25 | ofs << "11,22,33" << endl << "44" << endl; 26 | ofs << "1 2" << endl; 27 | 28 | ofs.close(); 29 | 30 | ifstream ifs; 31 | 32 | ifs.open("./hello_file_stream.txt"); 33 | 34 | if (!ifs) 35 | { 36 | cout << "open file fail!" << endl; 37 | } 38 | else 39 | { 40 | string line; 41 | 42 | getline(ifs, line); 43 | 44 | cout << line << endl; 45 | 46 | int n1,n2,n3,n4; 47 | 48 | ifs >> n1 >> skip_comma >> n2 >> skip_comma >> n3; 49 | cout << n1 << ", " << n2 << ", " << n3 << endl; 50 | ifs >> n4; 51 | cout << n4 << endl; 52 | 53 | n1 = n2 = -1; 54 | string spaces; 55 | //char c; 56 | ifs >> n1; 57 | 58 | ifs.unsetf(ios::skipws); 59 | ifs >> spaces; 60 | 61 | ifs.setf(ios::skipws); 62 | ifs >> n2; 63 | cout << n1 << "," << spaces << n2 << endl; 64 | } 65 | 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /03-feelling-1/3.15.4-HelloSTL_ScoreManage_Ver3/HelloSTL_ScoreManage_Ver3.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.15.4-HelloSTL_ScoreManage_Ver3/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.15.4-HelloSTL_ScoreManage_Ver3/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.2.2-HelloWorldCn/HelloWorldCn.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.2.2-HelloWorldCn/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.2.2-HelloWorldCn/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.3.3-HelloWorldFn/HelloWorldFn.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.3.3-HelloWorldFn/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | void Hello() 6 | { 7 | cout << "Hello! " << endl; 8 | } 9 | 10 | int main() 11 | { 12 | Hello(); 13 | Hello(); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /03-feelling-1/3.3.4-HelloWorldFn/HelloWorldFn.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.3.4-HelloWorldFn/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | void Hello(string const name) 6 | { 7 | cout << "Hello! " << name << "." << endl; 8 | } 9 | 10 | int main() 11 | { 12 | Hello("Xiao A"); 13 | Hello("BOSS"); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /03-feelling-1/3.4.4-HelloWorldInteractive/HelloWorldInteractive.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.4.4-HelloWorldInteractive/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | void Hello(string const name) 6 | { 7 | cout << "Hello! " << name << "." << endl; 8 | } 9 | 10 | int main() 11 | { 12 | string name = "Xiao A"; 13 | Hello(name); 14 | 15 | name = "BOSS"; 16 | Hello(name); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /03-feelling-1/3.4.5-HelloWorldInteractive/HelloWorldInteractive.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.4.5-HelloWorldInteractive/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | void Hello(string const name) 6 | { 7 | cout << "Hello! " << name << "." << endl; 8 | } 9 | 10 | int main() 11 | { 12 | string name; 13 | 14 | cout << "Please input the name: "; 15 | getline(cin, name); 16 | Hello(name); 17 | 18 | name = "BOSS"; 19 | Hello(name); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /03-feelling-1/3.5.2-HelloWorldIfElse/HelloWorldIfElse.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.5.2-HelloWorldIfElse/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.5.2-HelloWorldIfElse/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.5.3-HelloWorldIfElse/HelloWorldIfElse.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.5.3-HelloWorldIfElse/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.5.3-HelloWorldIfElse/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.6.2-HelloWorldWhile/HelloWorldWhile.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.6.2-HelloWorldWhile/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.6.2-HelloWorldWhile/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.7.2-HelloOO/HelloOO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.2-HelloOO/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | struct Object 6 | { 7 | 8 | }; 9 | 10 | int main() 11 | { 12 | Object o; 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.3-HelloOO/HelloOO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.3-HelloOO/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | struct Object 6 | { 7 | Object() 8 | { 9 | std::cout << "Hello world!" << endl; 10 | } 11 | }; 12 | 13 | int main() 14 | { 15 | Object o; 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.4-HelloOO/HelloOO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.4-HelloOO/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | struct Object 6 | { 7 | Object() 8 | { 9 | std::cout << "Hello world!" << endl; 10 | } 11 | 12 | ~Object() 13 | { 14 | std::cout << "Bye-bye world!" << endl; 15 | } 16 | }; 17 | 18 | int main() 19 | { 20 | Object o; 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.5-1-HelloOO/HelloOO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.5-1-HelloOO/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | struct Object 6 | { 7 | Object() 8 | { 9 | std::cout << "Hello world!" << endl; 10 | } 11 | 12 | ~Object() 13 | { 14 | std::cout << "Bye-bye world!" << endl; 15 | } 16 | }; 17 | 18 | int main() 19 | { 20 | Object o1; 21 | Object o2; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.5-2-HelloOO/HelloOO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.5-2-HelloOO/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | struct Object 6 | { 7 | Object() 8 | { 9 | std::cout << "Hello world!" << endl; 10 | } 11 | 12 | ~Object() 13 | { 14 | std::cout << "Bye-bye world!" << endl; 15 | } 16 | }; 17 | 18 | int main() 19 | { 20 | { 21 | Object o1; 22 | } 23 | 24 | Object o2; 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.5-3-HelloOO/HelloOO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.5-3-HelloOO/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.7.5-3-HelloOO/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.7.5-4-HelloOO/HelloOO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.5-4-HelloOO/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.7.5-4-HelloOO/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.7.7-1-HelloOO/HelloOO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.7-1-HelloOO/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.7.7-1-HelloOO/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.7.7-2-HelloOO/HelloOO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.7-2-HelloOO/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.7.7-2-HelloOO/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.7.7-3-HelloOO/HelloOO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.7.7-3-HelloOO/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.7.7-3-HelloOO/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.8.0-HelloOOMember/HelloOOMember.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.8.0-HelloOOMember/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | struct Person 7 | { 8 | Person() 9 | { 10 | cout << "Wa~Wa~" << endl; 11 | } 12 | 13 | ~Person() 14 | { 15 | cout << "Wu~Wu~" << endl; 16 | } 17 | }; 18 | 19 | int main() 20 | { 21 | Person xiaoA; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /03-feelling-1/3.8.1-1-HelloOOMember/HelloOOMember.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.8.1-1-HelloOOMember/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | struct Person 7 | { 8 | Person() 9 | { 10 | cout << "Wa~Wa~" << endl; 11 | } 12 | 13 | ~Person() 14 | { 15 | cout << "Wu~Wu~" << endl; 16 | } 17 | 18 | std::string name; 19 | }; 20 | 21 | int main() 22 | { 23 | Person xiaoA; 24 | xiaoA.name = "Xiao A"; 25 | 26 | Person *xiaoB = new Person; 27 | (*xiaoB).name = "Xiao B"; 28 | delete xiaoB; 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /03-feelling-1/3.8.1-2-HelloOOMember/HelloOOMember.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.8.1-2-HelloOOMember/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | struct Person 7 | { 8 | Person() 9 | { 10 | cout << "Wa~Wa~" << endl; 11 | } 12 | 13 | ~Person() 14 | { 15 | cout << "Wu~Wu~" << endl; 16 | } 17 | 18 | std::string name; 19 | }; 20 | 21 | int main() 22 | { 23 | Person xiaoA; 24 | xiaoA.name = "Xiao A"; 25 | 26 | Person *xiaoB = new Person; 27 | xiaoB->name = "Xiao B"; 28 | 29 | cout << xiaoA.name << endl; 30 | cout << xiaoB->name << endl; 31 | 32 | delete xiaoB; 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /03-feelling-1/3.8.2-HelloOOMember/HelloOOMember.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /03-feelling-1/3.8.2-HelloOOMember/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | struct Person 7 | { 8 | Person() 9 | { 10 | cout << "Wa~Wa~" << endl; 11 | } 12 | 13 | ~Person() 14 | { 15 | cout << "Wu~Wu~" << endl; 16 | } 17 | 18 | void Introduce() 19 | { 20 | cout << "Hi, my name is " << name << "." << endl; 21 | } 22 | 23 | std::string name; 24 | }; 25 | 26 | int main() 27 | { 28 | Person xiaoA; 29 | xiaoA.name = "Xiao A"; 30 | 31 | Person *xiaoB = new Person; 32 | xiaoB->name = "Xiao B"; 33 | 34 | xiaoA.Introduce(); 35 | xiaoB->Introduce(); 36 | 37 | delete xiaoB; 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /03-feelling-1/3.9.1-HelloOODerive/HelloOODerive.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.9.1-HelloOODerive/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.9.1-HelloOODerive/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.9.5-HelloOODerive/HelloOODerive.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.9.5-HelloOODerive/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.9.5-HelloOODerive/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.9.6-HelloOODerive/HelloOODerive.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.9.6-HelloOODerive/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.9.6-HelloOODerive/main.cpp -------------------------------------------------------------------------------- /03-feelling-1/3.9.7-HelloDerive_BBS/HelloDerive_BBS.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /03-feelling-1/3.9.7-HelloDerive_BBS/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/03-feelling-1/3.9.7-HelloDerive_BBS/main.cpp -------------------------------------------------------------------------------- /04-feeling-2/4.1-HelloGUI/HelloGUI.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 107 | 108 | -------------------------------------------------------------------------------- /04-feeling-2/4.1-HelloGUI/HelloGUIApp.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloGUIApp.h 3 | * Purpose: Defines Application Class 4 | * Author: NanYU (nanyu@sina.com) 5 | * Created: 2008-10-26 6 | * Copyright: NanYU (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOGUIAPP_H 11 | #define HELLOGUIAPP_H 12 | 13 | #include 14 | 15 | class HelloGUIApp : public wxApp 16 | { 17 | public: 18 | virtual bool OnInit(); 19 | }; 20 | 21 | #endif // HELLOGUIAPP_H 22 | -------------------------------------------------------------------------------- /04-feeling-2/4.1-HelloGUI/HelloGUIMain.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloGUIMain.cpp 3 | * Purpose: Code for Application Frame 4 | * Author: NanYU (nanyu@sina.com) 5 | * Created: 2008-10-26 6 | * Copyright: NanYU (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #include "HelloGUIMain.h" 11 | #include 12 | 13 | //(*InternalHeaders(HelloGUIDialog) 14 | #include 15 | #include 16 | #include 17 | #include 18 | //*) 19 | 20 | //helper functions 21 | enum wxbuildinfoformat { 22 | short_f, long_f }; 23 | 24 | wxString wxbuildinfo(wxbuildinfoformat format) 25 | { 26 | wxString wxbuild(wxVERSION_STRING); 27 | 28 | if (format == long_f ) 29 | { 30 | #if defined(__WXMSW__) 31 | wxbuild << _T("-Windows"); 32 | #elif defined(__UNIX__) 33 | wxbuild << _T("-Linux"); 34 | #endif 35 | 36 | #if wxUSE_UNICODE 37 | wxbuild << _T("-Unicode build"); 38 | #else 39 | wxbuild << _T("-ANSI build"); 40 | #endif // wxUSE_UNICODE 41 | } 42 | 43 | return wxbuild; 44 | } 45 | 46 | //(*IdInit(HelloGUIDialog) 47 | const long HelloGUIDialog::ID_STATICTEXT_WELCOME = wxNewId(); 48 | const long HelloGUIDialog::ID_BUTTON_ABOUT = wxNewId(); 49 | const long HelloGUIDialog::ID_STATICLINE1 = wxNewId(); 50 | const long HelloGUIDialog::ID_BUTTON_QUIT = wxNewId(); 51 | //*) 52 | 53 | BEGIN_EVENT_TABLE(HelloGUIDialog,wxDialog) 54 | //(*EventTable(HelloGUIDialog) 55 | //*) 56 | END_EVENT_TABLE() 57 | 58 | HelloGUIDialog::HelloGUIDialog(wxWindow* parent,wxWindowID id) 59 | { 60 | //(*Initialize(HelloGUIDialog) 61 | Create(parent, id, _("Hello GUI"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id")); 62 | BoxSizer1 = new wxBoxSizer(wxHORIZONTAL); 63 | StaticText1 = new wxStaticText(this, ID_STATICTEXT_WELCOME, _("欢迎使用\nwxWidgets!"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT_WELCOME")); 64 | wxFont StaticText1Font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); 65 | if ( !StaticText1Font.Ok() ) StaticText1Font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); 66 | StaticText1Font.SetPointSize(20); 67 | StaticText1->SetFont(StaticText1Font); 68 | BoxSizer1->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10); 69 | BoxSizer2 = new wxBoxSizer(wxVERTICAL); 70 | ButtonAbout = new wxButton(this, ID_BUTTON_ABOUT, _("关于"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON_ABOUT")); 71 | BoxSizer2->Add(ButtonAbout, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4); 72 | StaticLine1 = new wxStaticLine(this, ID_STATICLINE1, wxDefaultPosition, wxSize(10,-1), wxLI_HORIZONTAL, _T("ID_STATICLINE1")); 73 | BoxSizer2->Add(StaticLine1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4); 74 | ButtonQuit = new wxButton(this, ID_BUTTON_QUIT, _("退出"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON_QUIT")); 75 | BoxSizer2->Add(ButtonQuit, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4); 76 | BoxSizer1->Add(BoxSizer2, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4); 77 | SetSizer(BoxSizer1); 78 | BoxSizer1->Fit(this); 79 | BoxSizer1->SetSizeHints(this); 80 | 81 | Connect(ID_BUTTON_ABOUT,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&HelloGUIDialog::OnAbout); 82 | Connect(ID_BUTTON_QUIT,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&HelloGUIDialog::OnQuit); 83 | //*) 84 | } 85 | 86 | HelloGUIDialog::~HelloGUIDialog() 87 | { 88 | //(*Destroy(HelloGUIDialog) 89 | //*) 90 | } 91 | 92 | void HelloGUIDialog::OnQuit(wxCommandEvent& event) 93 | { 94 | Close(); 95 | } 96 | 97 | void HelloGUIDialog::OnAbout(wxCommandEvent& event) 98 | { 99 | wxString msg = wxbuildinfo(long_f); 100 | wxMessageBox(msg, _("Welcome to...")); 101 | } 102 | -------------------------------------------------------------------------------- /04-feeling-2/4.1-HelloGUI/HelloGUIMain.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloGUIMain.h 3 | * Purpose: Defines Application Frame 4 | * Author: NanYU (nanyu@sina.com) 5 | * Created: 2008-10-26 6 | * Copyright: NanYU (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOGUIMAIN_H 11 | #define HELLOGUIMAIN_H 12 | 13 | //(*Headers(HelloGUIDialog) 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | //*) 20 | 21 | class HelloGUIDialog: public wxDialog 22 | { 23 | public: 24 | 25 | HelloGUIDialog(wxWindow* parent,wxWindowID id = -1); 26 | virtual ~HelloGUIDialog(); 27 | 28 | private: 29 | 30 | //(*Handlers(HelloGUIDialog) 31 | void OnQuit(wxCommandEvent& event); 32 | void OnAbout(wxCommandEvent& event); 33 | //*) 34 | 35 | //(*Identifiers(HelloGUIDialog) 36 | static const long ID_STATICTEXT_WELCOME; 37 | static const long ID_BUTTON_ABOUT; 38 | static const long ID_STATICLINE1; 39 | static const long ID_BUTTON_QUIT; 40 | //*) 41 | 42 | //(*Declarations(HelloGUIDialog) 43 | wxButton* ButtonAbout; 44 | wxStaticText* StaticText1; 45 | wxBoxSizer* BoxSizer2; 46 | wxButton* ButtonQuit; 47 | wxStaticLine* StaticLine1; 48 | wxBoxSizer* BoxSizer1; 49 | //*) 50 | 51 | DECLARE_EVENT_TABLE() 52 | }; 53 | 54 | #endif // HELLOGUIMAIN_H 55 | -------------------------------------------------------------------------------- /04-feeling-2/4.1-HelloGUI/helloguiApp.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloGUIApp.cpp 3 | * Purpose: Code for Application Class 4 | * Author: NanYU (nanyu@sina.com) 5 | * Created: 2008-10-26 6 | * Copyright: NanYU (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #include "HelloGUIApp.h" 11 | 12 | //(*AppHeaders 13 | #include "HelloGUIMain.h" 14 | #include 15 | //*) 16 | 17 | IMPLEMENT_APP(HelloGUIApp); 18 | 19 | bool HelloGUIApp::OnInit() 20 | { 21 | //(*AppInitialize 22 | bool wxsOK = true; 23 | wxInitAllImageHandlers(); 24 | if ( wxsOK ) 25 | { 26 | HelloGUIDialog Dlg(0); 27 | SetTopWindow(&Dlg); 28 | Dlg.ShowModal(); 29 | wxsOK = false; 30 | } 31 | //*) 32 | return wxsOK; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /04-feeling-2/4.1-HelloGUI/obj/Debug/resource.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/04-feeling-2/4.1-HelloGUI/obj/Debug/resource.res -------------------------------------------------------------------------------- /04-feeling-2/4.1-HelloGUI/obj/Release/resource.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/04-feeling-2/4.1-HelloGUI/obj/Release/resource.res -------------------------------------------------------------------------------- /04-feeling-2/4.1-HelloGUI/resource.rc: -------------------------------------------------------------------------------- 1 | aaaa ICON "wx/msw/std.ico" 2 | 3 | #include "wx/msw/wx.rc" 4 | -------------------------------------------------------------------------------- /04-feeling-2/4.1-HelloGUI/wxsmith/HelloGUIdialog.wxs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello GUI 5 | 6 | 7 | 8 | 9 | 10 | 20 11 | wxSYS_DEFAULT_GUI_FONT 12 | 13 | 14 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 15 | 10 16 | 17 | 18 | 19 | 20 | wxVERTICAL 21 | 22 | 23 | 24 | 25 | 26 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 27 | 4 28 | 29 | 30 | 31 | 32 | 10,-1 33 | 34 | wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | 42 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 43 | 4 44 | 45 | 46 | 47 | wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 48 | 4 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /04-feeling-2/4.1-HelloGUI/wxsmith/HelloGUIframe.wxs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Alt-F4 10 | Quit the application 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | F1 19 | Show info about this application 20 | 21 | 22 | 23 | 24 | 25 | 1 26 | -1 27 | wxSB_NORMAL 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /04-feeling-2/4.2-HelloGUILayout/HelloGUILayout.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 108 | 109 | -------------------------------------------------------------------------------- /04-feeling-2/4.2-HelloGUILayout/HelloGUILayout.cscope_file_list: -------------------------------------------------------------------------------- 1 | "D:\bhcpp\project\feeling_2\HelloGUILayout\HelloGUILayoutApp.h" 2 | "D:\bhcpp\project\feeling_2\HelloGUILayout\HelloGUILayoutMain.cpp" 3 | "D:\bhcpp\project\feeling_2\HelloGUILayout\HelloGUILayoutMain.h" 4 | "D:\bhcpp\project\feeling_2\HelloGUILayout\resource.rc" 5 | "D:\bhcpp\project\feeling_2\HelloGUILayout\HelloGUILayoutApp.cpp" 6 | "D:\bhcpp\project\feeling_2\HelloGUILayout\wxsmith\HelloGUILayoutdialog.wxs" 7 | -------------------------------------------------------------------------------- /04-feeling-2/4.2-HelloGUILayout/HelloGUILayoutApp.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloGUILayoutApp.cpp 3 | * Purpose: Code for Application Class 4 | * Author: zhuangyan (nanu@sina.com) 5 | * Created: 2015-02-24 6 | * Copyright: zhuangyan (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #include "HelloGUILayoutApp.h" 11 | 12 | //(*AppHeaders 13 | #include "HelloGUILayoutMain.h" 14 | #include 15 | //*) 16 | 17 | IMPLEMENT_APP(HelloGUILayoutApp); 18 | 19 | bool HelloGUILayoutApp::OnInit() 20 | { 21 | //(*AppInitialize 22 | bool wxsOK = true; 23 | wxInitAllImageHandlers(); 24 | if ( wxsOK ) 25 | { 26 | HelloGUILayoutDialog Dlg(0); 27 | SetTopWindow(&Dlg); 28 | Dlg.ShowModal(); 29 | wxsOK = false; 30 | } 31 | //*) 32 | return wxsOK; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /04-feeling-2/4.2-HelloGUILayout/HelloGUILayoutApp.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloGUILayoutApp.h 3 | * Purpose: Defines Application Class 4 | * Author: zhuangyan (nanu@sina.com) 5 | * Created: 2015-02-24 6 | * Copyright: zhuangyan (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOGUILAYOUTAPP_H 11 | #define HELLOGUILAYOUTAPP_H 12 | 13 | #include 14 | 15 | class HelloGUILayoutApp : public wxApp 16 | { 17 | public: 18 | virtual bool OnInit(); 19 | }; 20 | 21 | #endif // HELLOGUILAYOUTAPP_H 22 | -------------------------------------------------------------------------------- /04-feeling-2/4.2-HelloGUILayout/HelloGUILayoutMain.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloGUILayoutMain.cpp 3 | * Purpose: Code for Application Frame 4 | * Author: zhuangyan (nanu@sina.com) 5 | * Created: 2015-02-24 6 | * Copyright: zhuangyan (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #include "HelloGUILayoutMain.h" 11 | #include 12 | 13 | //(*InternalHeaders(HelloGUILayoutDialog) 14 | #include 15 | #include 16 | #include 17 | #include 18 | //*) 19 | 20 | //helper functions 21 | enum wxbuildinfoformat { 22 | short_f, long_f }; 23 | 24 | wxString wxbuildinfo(wxbuildinfoformat format) 25 | { 26 | wxString wxbuild(wxVERSION_STRING); 27 | 28 | if (format == long_f ) 29 | { 30 | #if defined(__WXMSW__) 31 | wxbuild << _T("-Windows"); 32 | #elif defined(__UNIX__) 33 | wxbuild << _T("-Linux"); 34 | #endif 35 | 36 | #if wxUSE_UNICODE 37 | wxbuild << _T("-Unicode build"); 38 | #else 39 | wxbuild << _T("-ANSI build"); 40 | #endif // wxUSE_UNICODE 41 | } 42 | 43 | return wxbuild; 44 | } 45 | 46 | //(*IdInit(HelloGUILayoutDialog) 47 | const long HelloGUILayoutDialog::ID_STATICTEXT1 = wxNewId(); 48 | const long HelloGUILayoutDialog::ID_BUTTON3 = wxNewId(); 49 | const long HelloGUILayoutDialog::ID_BUTTON1 = wxNewId(); 50 | const long HelloGUILayoutDialog::ID_STATICLINE1 = wxNewId(); 51 | const long HelloGUILayoutDialog::ID_BUTTON2 = wxNewId(); 52 | //*) 53 | 54 | BEGIN_EVENT_TABLE(HelloGUILayoutDialog,wxDialog) 55 | //(*EventTable(HelloGUILayoutDialog) 56 | //*) 57 | END_EVENT_TABLE() 58 | 59 | HelloGUILayoutDialog::HelloGUILayoutDialog(wxWindow* parent,wxWindowID id) 60 | { 61 | //(*Initialize(HelloGUILayoutDialog) 62 | Create(parent, id, _("wxWidgets app"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id")); 63 | SetClientSize(wxSize(358,118)); 64 | BoxSizer1 = new wxBoxSizer(wxVERTICAL); 65 | StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Welcome to wxWidgets"), wxDefaultPosition, wxSize(335,66), wxALIGN_CENTRE|wxSTATIC_BORDER, _T("ID_STATICTEXT1")); 66 | wxFont StaticText1Font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); 67 | if ( !StaticText1Font.Ok() ) StaticText1Font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); 68 | StaticText1Font.SetPointSize(20); 69 | StaticText1->SetFont(StaticText1Font); 70 | BoxSizer1->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 10); 71 | BoxSizer2 = new wxBoxSizer(wxHORIZONTAL); 72 | BoxSizer2->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); 73 | Button3 = new wxButton(this, ID_BUTTON3, _("Hello GUI !"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3")); 74 | BoxSizer2->Add(Button3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); 75 | Button1 = new wxButton(this, ID_BUTTON1, _("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1")); 76 | BoxSizer2->Add(Button1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4); 77 | StaticLine1 = new wxStaticLine(this, ID_STATICLINE1, wxDefaultPosition, wxSize(2,24), wxLI_VERTICAL, _T("ID_STATICLINE1")); 78 | BoxSizer2->Add(StaticLine1, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4); 79 | Button2 = new wxButton(this, ID_BUTTON2, _("Quit"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2")); 80 | BoxSizer2->Add(Button2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4); 81 | BoxSizer1->Add(BoxSizer2, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4); 82 | SetSizer(BoxSizer1); 83 | SetSizer(BoxSizer1); 84 | Layout(); 85 | 86 | Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&HelloGUILayoutDialog::OnButton3Click); 87 | Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&HelloGUILayoutDialog::OnAbout); 88 | Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&HelloGUILayoutDialog::OnQuit); 89 | //*) 90 | } 91 | 92 | HelloGUILayoutDialog::~HelloGUILayoutDialog() 93 | { 94 | //(*Destroy(HelloGUILayoutDialog) 95 | //*) 96 | } 97 | 98 | void HelloGUILayoutDialog::OnQuit(wxCommandEvent& event) 99 | { 100 | Close(); 101 | } 102 | 103 | void HelloGUILayoutDialog::OnAbout(wxCommandEvent& event) 104 | { 105 | wxString msg = wxbuildinfo(long_f); 106 | wxMessageBox(msg, _("Welcome to...")); 107 | } 108 | 109 | void HelloGUILayoutDialog::OnButton3Click(wxCommandEvent& event) 110 | { 111 | this->StaticText1->SetLabel(wxT("Hello wxSmith !")); 112 | } 113 | -------------------------------------------------------------------------------- /04-feeling-2/4.2-HelloGUILayout/HelloGUILayoutMain.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloGUILayoutMain.h 3 | * Purpose: Defines Application Frame 4 | * Author: zhuangyan (nanu@sina.com) 5 | * Created: 2015-02-24 6 | * Copyright: zhuangyan (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOGUILAYOUTMAIN_H 11 | #define HELLOGUILAYOUTMAIN_H 12 | 13 | //(*Headers(HelloGUILayoutDialog) 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | //*) 20 | 21 | class HelloGUILayoutDialog: public wxDialog 22 | { 23 | public: 24 | 25 | HelloGUILayoutDialog(wxWindow* parent,wxWindowID id = -1); 26 | virtual ~HelloGUILayoutDialog(); 27 | 28 | private: 29 | 30 | //(*Handlers(HelloGUILayoutDialog) 31 | void OnQuit(wxCommandEvent& event); 32 | void OnAbout(wxCommandEvent& event); 33 | void OnButton3Click(wxCommandEvent& event); 34 | //*) 35 | 36 | //(*Identifiers(HelloGUILayoutDialog) 37 | static const long ID_STATICTEXT1; 38 | static const long ID_BUTTON3; 39 | static const long ID_BUTTON1; 40 | static const long ID_STATICLINE1; 41 | static const long ID_BUTTON2; 42 | //*) 43 | 44 | //(*Declarations(HelloGUILayoutDialog) 45 | wxButton* Button1; 46 | wxStaticText* StaticText1; 47 | wxBoxSizer* BoxSizer2; 48 | wxButton* Button2; 49 | wxButton* Button3; 50 | wxStaticLine* StaticLine1; 51 | wxBoxSizer* BoxSizer1; 52 | //*) 53 | 54 | DECLARE_EVENT_TABLE() 55 | }; 56 | 57 | #endif // HELLOGUILAYOUTMAIN_H 58 | -------------------------------------------------------------------------------- /04-feeling-2/4.2-HelloGUILayout/obj/Debug/resource.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/04-feeling-2/4.2-HelloGUILayout/obj/Debug/resource.res -------------------------------------------------------------------------------- /04-feeling-2/4.2-HelloGUILayout/obj/Release/resource.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/04-feeling-2/4.2-HelloGUILayout/obj/Release/resource.res -------------------------------------------------------------------------------- /04-feeling-2/4.2-HelloGUILayout/resource.rc: -------------------------------------------------------------------------------- 1 | aaaa ICON "wx/msw/std.ico" 2 | 3 | #include "wx/msw/wx.rc" 4 | -------------------------------------------------------------------------------- /04-feeling-2/4.2-HelloGUILayout/wxsmith/HelloGUILayoutdialog.wxs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | wxWidgets app 5 | 358,118 6 | 7 | wxVERTICAL 8 | 9 | 10 | 11 | 335,66 12 | 13 | 20 14 | wxSYS_DEFAULT_GUI_FONT 15 | 16 | 17 | 18 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 19 | 10 20 | 21 | 22 | 23 | 24 | 25 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 26 | 5 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 35 | 5 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 44 | 4 45 | 46 | 47 | 48 | 2,24 49 | 50 | 51 | wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 52 | 4 53 | 54 | 55 | 56 | 57 | 58 | 59 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 60 | 4 61 | 62 | 63 | wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 64 | 4 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /04-feeling-2/4.3-HelloInternet/HelloInternet.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 109 | 110 | -------------------------------------------------------------------------------- /04-feeling-2/4.3-HelloInternet/HelloInternetApp.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloInternetApp.cpp 3 | * Purpose: Code for Application Class 4 | * Author: NanYu (nanyu@sina.com) 5 | * Created: 2008-10-26 6 | * Copyright: NanYu (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #include "HelloInternetApp.h" 11 | 12 | //(*AppHeaders 13 | #include "HelloInternetMain.h" 14 | #include 15 | //*) 16 | 17 | IMPLEMENT_APP(HelloInternetApp); 18 | 19 | bool HelloInternetApp::OnInit() 20 | { 21 | //(*AppInitialize 22 | bool wxsOK = true; 23 | wxInitAllImageHandlers(); 24 | if ( wxsOK ) 25 | { 26 | HelloInternetDialog Dlg(0); 27 | SetTopWindow(&Dlg); 28 | Dlg.ShowModal(); 29 | wxsOK = false; 30 | } 31 | //*) 32 | return wxsOK; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /04-feeling-2/4.3-HelloInternet/HelloInternetApp.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloInternetApp.h 3 | * Purpose: Defines Application Class 4 | * Author: NanYu (nanyu@sina.com) 5 | * Created: 2008-10-26 6 | * Copyright: NanYu (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOINTERNETAPP_H 11 | #define HELLOINTERNETAPP_H 12 | 13 | #include 14 | 15 | class HelloInternetApp : public wxApp 16 | { 17 | public: 18 | virtual bool OnInit(); 19 | }; 20 | 21 | #endif // HELLOINTERNETAPP_H 22 | -------------------------------------------------------------------------------- /04-feeling-2/4.3-HelloInternet/HelloInternetMain.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloInternetMain.h 3 | * Purpose: Defines Application Frame 4 | * Author: NanYu (nanyu@sina.com) 5 | * Created: 2008-10-26 6 | * Copyright: NanYu (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOINTERNETMAIN_H 11 | #define HELLOINTERNETMAIN_H 12 | 13 | //(*Headers(HelloInternetDialog) 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | //*) 21 | 22 | class HelloInternetDialog: public wxDialog 23 | { 24 | public: 25 | 26 | HelloInternetDialog(wxWindow* parent,wxWindowID id = -1); 27 | virtual ~HelloInternetDialog(); 28 | 29 | private: 30 | 31 | //(*Handlers(HelloInternetDialog) 32 | void OnQuit(wxCommandEvent& event); 33 | void OnAbout(wxCommandEvent& event); 34 | void OnButton3Click(wxCommandEvent& event); 35 | //*) 36 | 37 | //(*Identifiers(HelloInternetDialog) 38 | static const long ID_STATICTEXT2; 39 | static const long ID_TEXTCTRL1; 40 | static const long ID_BUTTON3; 41 | static const long ID_STATICTEXT1; 42 | static const long ID_BUTTON1; 43 | static const long ID_STATICLINE1; 44 | static const long ID_BUTTON2; 45 | //*) 46 | 47 | //(*Declarations(HelloInternetDialog) 48 | wxStaticText* StaticText2; 49 | wxButton* Button1; 50 | wxStaticText* StaticText1; 51 | wxBoxSizer* BoxSizer2; 52 | wxButton* Button2; 53 | wxButton* Button3; 54 | wxStaticLine* StaticLine1; 55 | wxBoxSizer* BoxSizer1; 56 | wxTextCtrl* TextCtrl1; 57 | //*) 58 | 59 | DECLARE_EVENT_TABLE() 60 | }; 61 | 62 | #endif // HELLOINTERNETMAIN_H 63 | -------------------------------------------------------------------------------- /04-feeling-2/4.3-HelloInternet/aaa.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/04-feeling-2/4.3-HelloInternet/aaa.txt -------------------------------------------------------------------------------- /04-feeling-2/4.3-HelloInternet/obj/Debug/resource.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/04-feeling-2/4.3-HelloInternet/obj/Debug/resource.res -------------------------------------------------------------------------------- /04-feeling-2/4.3-HelloInternet/obj/Release/resource.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/04-feeling-2/4.3-HelloInternet/obj/Release/resource.res -------------------------------------------------------------------------------- /04-feeling-2/4.3-HelloInternet/resource.rc: -------------------------------------------------------------------------------- 1 | aaaa ICON "wx/msw/std.ico" 2 | 3 | #include "wx/msw/wx.rc" 4 | -------------------------------------------------------------------------------- /04-feeling-2/4.3-HelloInternet/wxsmith/HelloInternetdialog.wxs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello Internet 5 | 481,112 6 | 0 7 | 8 | 9 | 10 | wxVERTICAL 11 | 12 | 13 | 14 | 15 | wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 16 | 5 17 | 18 | 19 | 20 | 21 | 丁小明 22 | 117,24 23 | 24 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 25 | 5 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 34 | 5 35 | 36 | 37 | 38 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 39 | 5 40 | 41 | 42 | 43 | 44 | 269,67 45 | 46 | 14 47 | 48 | normal 49 | 0 50 | swiss 51 | 宋体 52 | 53 | 54 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 55 | 10 56 | 57 | 58 | 59 | 60 | wxVERTICAL 61 | 62 | 63 | 64 | 65 | 66 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 67 | 4 68 | 69 | 70 | 71 | 72 | 10,-1 73 | 74 | wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 75 | 4 76 | 77 | 78 | 79 | 80 | 81 | 82 | wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 83 | 4 84 | 85 | 86 | 87 | wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL 88 | 4 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /04-feeling-2/4.4-HelloDatabase_Console/HelloDatabase_Console.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 52 | 53 | -------------------------------------------------------------------------------- /04-feeling-2/4.4-HelloDatabase_Console/backup_d2school_champions_2008.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/04-feeling-2/4.4-HelloDatabase_Console/backup_d2school_champions_2008.7z -------------------------------------------------------------------------------- /04-feeling-2/4.4-HelloDatabase_Console/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/04-feeling-2/4.4-HelloDatabase_Console/main.cpp -------------------------------------------------------------------------------- /05-base/5.10-FloatPointNumberDemo1/FloatPointNumberDemo1.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /05-base/5.10-FloatPointNumberDemo1/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | if (1.0 / 2.0 == 0.5f) 8 | { 9 | cout << "yes!" << endl; 10 | } 11 | else 12 | { 13 | cout << "NO~~~" << endl; 14 | } 15 | 16 | if (0.01f * 10.0f / 0.2f == 0.5f) 17 | { 18 | cout << "yes!" << endl; 19 | } 20 | else 21 | { 22 | cout << "no." << endl; 23 | } 24 | 25 | float f = 0.5f; 26 | 27 | cout << "sizeof float = " << sizeof(float) << "=" << sizeof(f) << endl; 28 | cout << f << endl; 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /05-base/5.2-BuildDemo/a.cpp: -------------------------------------------------------------------------------- 1 | /* a.cpp */ 2 | 3 | void foo(); 4 | 5 | int main() 6 | { 7 | foo(); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /05-base/5.2-BuildDemo/b.cpp: -------------------------------------------------------------------------------- 1 | /* b.cpp */ 2 | 3 | #include 4 | 5 | void foo() 6 | { 7 | std::cout << "system build!" << std::endl; 8 | } 9 | -------------------------------------------------------------------------------- /05-base/5.3-IncludeDemo1/IncludeDemo1.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 45 | 46 | -------------------------------------------------------------------------------- /05-base/5.3-IncludeDemo1/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "my_file.hpp" //引入MyStruct和my_function 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | MyStruct myStruct; 10 | 11 | my_function(1974, 4, 20); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /05-base/5.3-IncludeDemo1/my_file.cpp: -------------------------------------------------------------------------------- 1 | #include "my_file.hpp" //包含自定义的头文件 2 | 3 | #include //包含标准库文件 4 | 5 | using namespace std; 6 | 7 | MyStruct::MyStruct() 8 | { 9 | cout << "MyStruct Construct." << endl; 10 | } 11 | 12 | MyStruct::~MyStruct() 13 | { 14 | cout << "MyStruct Destruct." << endl; 15 | } 16 | 17 | void my_function(int year, int month, int day) 18 | { 19 | cout << year << '-' << month << '-' << day << endl; 20 | } 21 | -------------------------------------------------------------------------------- /05-base/5.3-IncludeDemo1/my_file.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _MY_FILE_HPP_ 2 | #define _MY_FILE_HPP_ 3 | 4 | //定义一个类 5 | struct MyStruct 6 | { 7 | MyStruct(); 8 | ~MyStruct(); 9 | }; 10 | 11 | //声明一个函数: 12 | void my_function(int year, int month, int day); 13 | 14 | #endif //my_file.hpp 15 | -------------------------------------------------------------------------------- /05-base/5.3-IncludeDemo1/my_file2.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /05-base/5.4-MemoryAllocTest/MemoryAllocTest.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /05-base/5.4-MemoryAllocTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | unsigned int bytes = 0; 8 | 9 | while(true) 10 | { 11 | try 12 | { 13 | new char [1024 * 4]; 14 | bytes += 1024 * 4; 15 | } 16 | catch(std::exception const & e) 17 | { 18 | std::cout << e.what() << std::endl; 19 | break; 20 | } 21 | } 22 | 23 | std::cout << bytes << "bytes" << std::endl; 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /05-base/5.5-1-GlobalVarTest/GlobalVarTest.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 42 | 43 | -------------------------------------------------------------------------------- /05-base/5.5-1-GlobalVarTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | struct Object 6 | { 7 | Object() 8 | { 9 | std::cout << "Hello world!" << endl; 10 | } 11 | 12 | ~Object() 13 | { 14 | std::cout << "Bye-bye world!" << endl; 15 | } 16 | 17 | private: 18 | std::string name_; 19 | }; 20 | 21 | Object oa,ob,oc; //这里定义了三个全局变量 22 | 23 | int main() 24 | { 25 | std::cout << "main()" << std::endl; 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /05-base/5.5-2-StackVarTest/StackVarTest.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /05-base/5.5-2-StackVarTest/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | struct Object 6 | { 7 | Object(std::string const & name) 8 | { 9 | name_ = name; 10 | std::cout << name_ << ": Hello world!" << endl; 11 | } 12 | 13 | ~Object() 14 | { 15 | std::cout << name_ << ": Bye-bye world!" << endl; 16 | } 17 | 18 | private: 19 | std::string name_; 20 | }; 21 | 22 | int main() 23 | { 24 | {//----------第一层开始----------------------- 25 | std::cout << "enter 1" << std::endl; 26 | Object o("a"); 27 | 28 | {//----------第二层开始----------------------- 29 | std::cout << "enter 2" << std::endl; 30 | Object o("b"); 31 | 32 | {//----------第三层开始----------------------- 33 | std::cout << "enter 3" << std::endl; 34 | Object o("c"); 35 | }//----------第三层结束----------------------- 36 | std::cout << "exit 3" << std::endl; 37 | 38 | }//----------第二层结束----------------------- 39 | std::cout << "exit 2" << std::endl; 40 | 41 | }//----------第三层结束----------------------- 42 | std::cout << "exit 1" << std::endl; 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /05-base/5.8-1-VarDemo1/VarDemo1.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /05-base/5.8-1-VarDemo1/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a; 8 | 9 | cout << "----代码: int a;----" << endl; 10 | cout << "变量a的值为: " << a << endl; 11 | cout << "变量a的内存地址为: " << &a << endl; 12 | cout << "变量a占用的内存尺寸为: " << sizeof(a) << "个字节" << endl; 13 | cout << "变量a的运行期类型信息名称为: " << typeid(a).name() << endl; 14 | 15 | a = 1; 16 | 17 | cout << "----代码: a = 1; 之后----" << endl; 18 | cout << "变量a的值为: " << a << endl; 19 | cout << "变量a的内存地址为: " << &a << endl; 20 | cout << "变量a占用的内存尺寸为: " << sizeof(a) << "个字节" << endl; 21 | cout << "变量a的运行期类型信息名称为: " << typeid(a).name() << endl; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /05-base/5.8-2-PtrVarDemo1/PtrVarDemo1.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /05-base/5.8-2-PtrVarDemo1/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/05-base/5.8-2-PtrVarDemo1/main.cpp -------------------------------------------------------------------------------- /05-base/5.8-3-ArrayVarDemo1/ArrayVarDemo1.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /05-base/5.8-3-ArrayVarDemo1/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/05-base/5.8-3-ArrayVarDemo1/main.cpp -------------------------------------------------------------------------------- /05-base/5.8-3-ArrayVarDemo1/main2.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /06-ide/6.10-WorkspaceDemo/AppDemo/AppDemo.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 53 | 54 | -------------------------------------------------------------------------------- /06-ide/6.10-WorkspaceDemo/AppDemo/a.txt: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /06-ide/6.10-WorkspaceDemo/AppDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | extern int from_share_lib (int n1, int n2); 6 | extern double from_static_lib (int n1, int n2); 7 | 8 | int main() 9 | { 10 | int n1,n2; 11 | 12 | cout << "please input n1, n2 : "; 13 | 14 | cin >> n1 >> n2; 15 | 16 | int tmp = from_share_lib(n1, n2); 17 | double result = from_static_lib(n1, tmp); 18 | 19 | cout << "result is " << result << endl; 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /06-ide/6.10-WorkspaceDemo/ShareLibDemo/ShareLibDemo.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 48 | 49 | -------------------------------------------------------------------------------- /06-ide/6.10-WorkspaceDemo/ShareLibDemo/bin/Debug/libShareLibDemo.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | _Z14from_share_libii @1 3 | _get_output_format @2 4 | -------------------------------------------------------------------------------- /06-ide/6.10-WorkspaceDemo/ShareLibDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int from_share_lib (int n1, int n2) 6 | { 7 | cout << __func__ << endl; 8 | 9 | int r = n1 + n2; 10 | 11 | return r; 12 | } 13 | -------------------------------------------------------------------------------- /06-ide/6.10-WorkspaceDemo/StaticLibDemo/StaticLibDemo.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 45 | 46 | -------------------------------------------------------------------------------- /06-ide/6.10-WorkspaceDemo/StaticLibDemo/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | double from_static_lib (int n1, int n2) 6 | { 7 | cout << __func__ << endl; 8 | 9 | int r = n1 / n2; 10 | 11 | return r; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /06-ide/6.10-WorkspaceDemo/WorkspaceDemo.workspace: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /06-ide/6.2-header_fixup/header_fixup.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | -------------------------------------------------------------------------------- /06-ide/6.2-header_fixup/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | ofstream ofs; 8 | 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /06-ide/6.8-ProjectSettingDemo/ProjectSettingDemo.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 111 | 112 | -------------------------------------------------------------------------------- /06-ide/6.8-ProjectSettingDemo/ProjectSettingDemoApp.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: ProjectSettingDemoApp.cpp 3 | * Purpose: Code for Application Class 4 | * Author: nanyu (nanyu@sina.com.cn) 5 | * Created: 2009-12-12 6 | * Copyright: nanyu (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #include "ProjectSettingDemoApp.h" 11 | 12 | //(*AppHeaders 13 | #include "ProjectSettingDemoMain.h" 14 | #include 15 | //*) 16 | 17 | IMPLEMENT_APP(ProjectSettingDemoApp); 18 | 19 | bool ProjectSettingDemoApp::OnInit() 20 | { 21 | //(*AppInitialize 22 | bool wxsOK = true; 23 | wxInitAllImageHandlers(); 24 | if ( wxsOK ) 25 | { 26 | ProjectSettingDemoDialog Dlg(0); 27 | SetTopWindow(&Dlg); 28 | Dlg.ShowModal(); 29 | wxsOK = false; 30 | } 31 | //*) 32 | return wxsOK; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /06-ide/6.8-ProjectSettingDemo/ProjectSettingDemoApp.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: ProjectSettingDemoApp.h 3 | * Purpose: Defines Application Class 4 | * Author: nanyu (nanyu@sina.com.cn) 5 | * Created: 2009-12-12 6 | * Copyright: nanyu (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef PROJECTSETTINGDEMOAPP_H 11 | #define PROJECTSETTINGDEMOAPP_H 12 | 13 | #include 14 | 15 | class ProjectSettingDemoApp : public wxApp 16 | { 17 | public: 18 | virtual bool OnInit(); 19 | }; 20 | 21 | #endif // PROJECTSETTINGDEMOAPP_H 22 | -------------------------------------------------------------------------------- /06-ide/6.8-ProjectSettingDemo/ProjectSettingDemoMain.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: ProjectSettingDemoMain.cpp 3 | * Purpose: Code for Application Frame 4 | * Author: nanyu (nanyu@sina.com.cn) 5 | * Created: 2009-12-12 6 | * Copyright: nanyu (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #include "ProjectSettingDemoMain.h" 11 | #include 12 | 13 | //(*InternalHeaders(ProjectSettingDemoDialog) 14 | #include 15 | #include 16 | //*) 17 | 18 | //helper functions 19 | enum wxbuildinfoformat { 20 | short_f, long_f }; 21 | 22 | wxString wxbuildinfo(wxbuildinfoformat format) 23 | { 24 | wxString wxbuild(wxVERSION_STRING); 25 | 26 | if (format == long_f ) 27 | { 28 | #if defined(__WXMSW__) 29 | wxbuild << _T("-Windows"); 30 | #elif defined(__UNIX__) 31 | wxbuild << _T("-Linux"); 32 | #endif 33 | 34 | #if wxUSE_UNICODE 35 | wxbuild << _T("-Unicode build"); 36 | #else 37 | wxbuild << _T("-ANSI build"); 38 | #endif // wxUSE_UNICODE 39 | } 40 | 41 | return wxbuild; 42 | } 43 | 44 | //(*IdInit(ProjectSettingDemoDialog) 45 | //*) 46 | 47 | BEGIN_EVENT_TABLE(ProjectSettingDemoDialog,wxDialog) 48 | //(*EventTable(ProjectSettingDemoDialog) 49 | //*) 50 | END_EVENT_TABLE() 51 | 52 | ProjectSettingDemoDialog::ProjectSettingDemoDialog(wxWindow* parent,wxWindowID id) 53 | { 54 | //(*Initialize(ProjectSettingDemoDialog) 55 | Create(parent, id, _("wxWidgets app"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER, _T("id")); 56 | SetClientSize(wxSize(345,214)); 57 | 58 | Connect(wxEVT_SIZE,(wxObjectEventFunction)&ProjectSettingDemoDialog::OnResize); 59 | //*) 60 | } 61 | 62 | ProjectSettingDemoDialog::~ProjectSettingDemoDialog() 63 | { 64 | //(*Destroy(ProjectSettingDemoDialog) 65 | //*) 66 | } 67 | 68 | void ProjectSettingDemoDialog::OnQuit(wxCommandEvent& event) 69 | { 70 | Close(); 71 | } 72 | 73 | void ProjectSettingDemoDialog::OnAbout(wxCommandEvent& event) 74 | { 75 | wxString msg = wxbuildinfo(long_f); 76 | wxMessageBox(msg, _("Welcome to...")); 77 | } 78 | 79 | void ProjectSettingDemoDialog::OnResize(wxSizeEvent& event) 80 | { 81 | } 82 | -------------------------------------------------------------------------------- /06-ide/6.8-ProjectSettingDemo/ProjectSettingDemoMain.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: ProjectSettingDemoMain.h 3 | * Purpose: Defines Application Frame 4 | * Author: nanyu (nanyu@sina.com.cn) 5 | * Created: 2009-12-12 6 | * Copyright: nanyu (www.d2school.com) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef PROJECTSETTINGDEMOMAIN_H 11 | #define PROJECTSETTINGDEMOMAIN_H 12 | 13 | //(*Headers(ProjectSettingDemoDialog) 14 | #include 15 | //*) 16 | 17 | class ProjectSettingDemoDialog: public wxDialog 18 | { 19 | public: 20 | 21 | ProjectSettingDemoDialog(wxWindow* parent,wxWindowID id = -1); 22 | virtual ~ProjectSettingDemoDialog(); 23 | 24 | private: 25 | 26 | //(*Handlers(ProjectSettingDemoDialog) 27 | void OnQuit(wxCommandEvent& event); 28 | void OnAbout(wxCommandEvent& event); 29 | void OnResize(wxSizeEvent& event); 30 | //*) 31 | 32 | //(*Identifiers(ProjectSettingDemoDialog) 33 | //*) 34 | 35 | //(*Declarations(ProjectSettingDemoDialog) 36 | //*) 37 | 38 | DECLARE_EVENT_TABLE() 39 | }; 40 | 41 | #endif // PROJECTSETTINGDEMOMAIN_H 42 | -------------------------------------------------------------------------------- /06-ide/6.8-ProjectSettingDemo/lib_finder.script: -------------------------------------------------------------------------------- 1 | function SetBuildOptions(base) 2 | { 3 | if ( "LibFinder" in getroottable() ) 4 | { 5 | LibFinder.SetupTarget(base); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /06-ide/6.8-ProjectSettingDemo/obj/Debug/resource.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/06-ide/6.8-ProjectSettingDemo/obj/Debug/resource.res -------------------------------------------------------------------------------- /06-ide/6.8-ProjectSettingDemo/resource.rc: -------------------------------------------------------------------------------- 1 | aaaa ICON "wx/msw/std.ico" 2 | 3 | #include "wx/msw/wx.rc" 4 | -------------------------------------------------------------------------------- /06-ide/6.8-ProjectSettingDemo/wxsmith/ProjectSettingDemodialog.wxs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | wxWidgets app 5 | 345,214 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /10-stl_and_boost/10.1.1-OutputDebugInfo/OutputDebugInfo.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 38 | 39 | -------------------------------------------------------------------------------- /10-stl_and_boost/10.1.1-OutputDebugInfo/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/10-stl_and_boost/10.1.1-OutputDebugInfo/main.cpp -------------------------------------------------------------------------------- /10-stl_and_boost/10.1.2-SyncCppAndCStdIO/01-SyncInput/SyncInput.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 40 | 41 | -------------------------------------------------------------------------------- /10-stl_and_boost/10.1.2-SyncCppAndCStdIO/01-SyncInput/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/10-stl_and_boost/10.1.2-SyncCppAndCStdIO/01-SyncInput/main.cpp -------------------------------------------------------------------------------- /10-stl_and_boost/10.1.2-SyncCppAndCStdIO/02-SyncOutput/SyncOutput.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 38 | 39 | -------------------------------------------------------------------------------- /10-stl_and_boost/10.1.2-SyncCppAndCStdIO/02-SyncOutput/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | ios_base::sync_with_stdio(false); 9 | 10 | for (int i=0; i<3; ++i) 11 | { 12 | printf("hello from printf!\n"); 13 | cout << "hello from cout.\n"; 14 | } 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /10-stl_and_boost/10.1.2-SyncCppAndCStdIO/03-PerformancePK/PerformancePK.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 40 | 41 | -------------------------------------------------------------------------------- /10-stl_and_boost/10.1.2-SyncCppAndCStdIO/03-PerformancePK/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | ios::sync_with_stdio(false); 10 | 11 | clock_t beg = clock(); 12 | 13 | for (int i=0; i<30000; ++i) 14 | { 15 | cout << "hello world."; 16 | } 17 | 18 | 19 | clock_t end = clock(); 20 | cout << "\n" << (end - beg) * 1000 / CLOCKS_PER_SEC << "ms." < 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /10-stl_and_boost/10.1.3-FormatIO/FormatIO.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 40 | 41 | -------------------------------------------------------------------------------- /10-stl_and_boost/10.1.3-FormatIO/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/10-stl_and_boost/10.1.3-FormatIO/main.cpp -------------------------------------------------------------------------------- /11-GUI/11.1-RedX/DesktopX/DesktopX.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 50 | 51 | -------------------------------------------------------------------------------- /11-GUI/11.1-RedX/DesktopX/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/11-GUI/11.1-RedX/DesktopX/main.cpp -------------------------------------------------------------------------------- /11-GUI/11.1-RedX/DesktopX/manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /11-GUI/11.1-RedX/DesktopX/resource.h: -------------------------------------------------------------------------------- 1 | #ifndef IDC_STATIC 2 | #define IDC_STATIC (-1) 3 | #endif 4 | 5 | #define DLG_MAIN 100 6 | -------------------------------------------------------------------------------- /11-GUI/11.1-RedX/DesktopX/resource.rc: -------------------------------------------------------------------------------- 1 | // Generated by ResEdit 1.5.10 2 | // Copyright (C) 2006-2012 3 | // http://www.resedit.net 4 | 5 | #include 6 | #include 7 | #include 8 | #include "resource.h" 9 | 10 | 11 | 12 | 13 | // 14 | // Dialog resources 15 | // 16 | LANGUAGE 0, SUBLANG_NEUTRAL 17 | DLG_MAIN DIALOG 0, 0, 186, 95 18 | STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU 19 | CAPTION "Dialog" 20 | FONT 8, "Ms Shell Dlg" 21 | { 22 | } 23 | 24 | 25 | 26 | // 27 | // Manifest resources 28 | // 29 | LANGUAGE 0, SUBLANG_NEUTRAL 30 | 1 RT_MANIFEST ".\\manifest.xml" 31 | -------------------------------------------------------------------------------- /11-GUI/11.1-RedX/readme.txt: -------------------------------------------------------------------------------- 1 | DesktopX - GUI 最开始的附加课程《在桌面上打个大红叉》 -------------------------------------------------------------------------------- /11-GUI/11.2-Win32GUI/HelloWin32/HelloWin32.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 45 | 46 | -------------------------------------------------------------------------------- /11-GUI/11.2-Win32GUI/HelloWin32/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/d2school/bhcpp/e5d832d16044cee3c9e2cd1ea84c65ba8012f2ce/11-GUI/11.2-Win32GUI/HelloWin32/main.cpp -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.2/HelloWxWidgets/HelloWxWidgets.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 94 | 95 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.2/HelloWxWidgets/HelloWxWidgetsApp.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloWxWidgetsApp.cpp 3 | * Purpose: Code for Application Class 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2023-08-05 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifdef WX_PRECOMP 11 | #include "wx_pch.h" 12 | #endif 13 | 14 | #ifdef __BORLANDC__ 15 | #pragma hdrstop 16 | #endif //__BORLANDC__ 17 | 18 | #include "HelloWxWidgetsApp.h" 19 | #include "HelloWxWidgetsMain.h" 20 | 21 | IMPLEMENT_APP(HelloWxWidgetsApp); 22 | 23 | bool HelloWxWidgetsApp::OnInit() 24 | { 25 | HelloWxWidgetsFrame* frame = new HelloWxWidgetsFrame(0L, _("wxWidgets Application Template")); 26 | frame->SetIcon(wxICON(aaaa)); // To Set App Icon 27 | frame->Show(); 28 | 29 | return true; 30 | } 31 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.2/HelloWxWidgets/HelloWxWidgetsApp.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloWxWidgetsApp.h 3 | * Purpose: Defines Application Class 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2023-08-05 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOWXWIDGETSAPP_H 11 | #define HELLOWXWIDGETSAPP_H 12 | 13 | #include 14 | 15 | class HelloWxWidgetsApp : public wxApp 16 | { 17 | public: 18 | virtual bool OnInit(); 19 | }; 20 | 21 | #endif // HELLOWXWIDGETSAPP_H 22 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.2/HelloWxWidgets/HelloWxWidgetsMain.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloWxWidgetsMain.cpp 3 | * Purpose: Code for Application Frame 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2023-08-05 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifdef WX_PRECOMP 11 | #include "wx_pch.h" 12 | #endif 13 | 14 | #ifdef __BORLANDC__ 15 | #pragma hdrstop 16 | #endif //__BORLANDC__ 17 | 18 | #include "HelloWxWidgetsMain.h" 19 | 20 | //helper functions 21 | 22 | BEGIN_EVENT_TABLE(HelloWxWidgetsFrame, wxFrame) 23 | EVT_CLOSE(HelloWxWidgetsFrame::OnClose) 24 | EVT_MENU(idMenuQuit, HelloWxWidgetsFrame::OnQuit) 25 | 26 | EVT_MOTION(HelloWxWidgetsFrame::OnMotion) 27 | EVT_PAINT(HelloWxWidgetsFrame::OnPaint) 28 | END_EVENT_TABLE() 29 | 30 | HelloWxWidgetsFrame::HelloWxWidgetsFrame(wxFrame *frame, const wxString& title) 31 | : wxFrame(frame, -1, title) 32 | { 33 | } 34 | 35 | 36 | HelloWxWidgetsFrame::~HelloWxWidgetsFrame() 37 | { 38 | } 39 | 40 | void HelloWxWidgetsFrame::OnClose(wxCloseEvent &event) 41 | { 42 | Destroy(); 43 | } 44 | 45 | void HelloWxWidgetsFrame::OnQuit(wxCommandEvent &event) 46 | { 47 | Destroy(); 48 | } 49 | 50 | void HelloWxWidgetsFrame::OnMotion(wxMouseEvent& event) 51 | { 52 | this->xPos = event.GetPosition().x; 53 | this->yPos = event.GetPosition().y; 54 | 55 | this->Refresh(); 56 | } 57 | 58 | void HelloWxWidgetsFrame::OnPaint(wxPaintEvent& event) 59 | { 60 | wxPaintDC dc (this); 61 | 62 | wxString txt; 63 | txt << wxT("[") << xPos << wxT(" | ") << yPos << wxT("]-来自d2school (Windows)"); 64 | dc.DrawText(txt, xPos + 10, yPos + 10); 65 | } 66 | 67 | 68 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.2/HelloWxWidgets/HelloWxWidgetsMain.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloWxWidgetsMain.h 3 | * Purpose: Defines Application Frame 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2023-08-05 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOWXWIDGETSMAIN_H 11 | #define HELLOWXWIDGETSMAIN_H 12 | 13 | #ifndef WX_PRECOMP 14 | #include 15 | #endif 16 | 17 | #include "HelloWxWidgetsApp.h" 18 | 19 | class HelloWxWidgetsFrame: public wxFrame 20 | { 21 | public: 22 | HelloWxWidgetsFrame(wxFrame *frame, const wxString& title); 23 | ~HelloWxWidgetsFrame(); 24 | private: 25 | enum 26 | { 27 | idMenuQuit = 1000, 28 | idMenuAbout 29 | }; 30 | void OnClose(wxCloseEvent& event); 31 | void OnQuit(wxCommandEvent& event); 32 | 33 | void OnMotion(wxMouseEvent& event); 34 | void OnPaint(wxPaintEvent& event); 35 | 36 | DECLARE_EVENT_TABLE() 37 | 38 | private: 39 | int xPos = 0, yPos = 0; 40 | }; 41 | 42 | 43 | #endif // HELLOWXWIDGETSMAIN_H 44 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.2/HelloWxWidgets/resource.rc: -------------------------------------------------------------------------------- 1 | aaaa ICON "wx/msw/std.ico" 2 | 3 | #include "wx/msw/wx.rc" 4 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.3/HelloMyFrame/HelloMyFrame.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 94 | 95 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.3/HelloMyFrame/HelloMyFrameApp.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloMyFrameApp.cpp 3 | * Purpose: Code for Application Class 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2024-04-11 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifdef WX_PRECOMP 11 | #include "wx_pch.h" 12 | #endif 13 | 14 | #ifdef __BORLANDC__ 15 | #pragma hdrstop 16 | #endif //__BORLANDC__ 17 | 18 | #include "HelloMyFrameApp.h" 19 | #include "HelloMyFrameMain.h" 20 | 21 | IMPLEMENT_APP(HelloMyFrameApp); 22 | 23 | bool HelloMyFrameApp::OnInit() 24 | { 25 | HelloMyFrameFrame* frame = new HelloMyFrameFrame(0L, _("wxWidgets Application Template")); 26 | frame->SetIcon(wxICON(aaaa)); // To Set App Icon 27 | frame->Show(); 28 | 29 | return true; 30 | } 31 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.3/HelloMyFrame/HelloMyFrameApp.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloMyFrameApp.h 3 | * Purpose: Defines Application Class 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2024-04-11 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOMYFRAMEAPP_H 11 | #define HELLOMYFRAMEAPP_H 12 | 13 | #include 14 | 15 | class HelloMyFrameApp : public wxApp 16 | { 17 | public: 18 | virtual bool OnInit(); 19 | }; 20 | 21 | #endif // HELLOMYFRAMEAPP_H 22 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.3/HelloMyFrame/HelloMyFrameMain.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloMyFrameMain.h 3 | * Purpose: Defines Application Frame 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2024-04-11 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOMYFRAMEMAIN_H 11 | #define HELLOMYFRAMEMAIN_H 12 | 13 | #ifndef WX_PRECOMP 14 | #include 15 | #endif 16 | 17 | #include "HelloMyFrameApp.h" 18 | 19 | class HelloMyFrameFrame: public wxFrame 20 | { 21 | public: 22 | HelloMyFrameFrame(wxFrame *frame, const wxString& title); 23 | ~HelloMyFrameFrame(); 24 | private: 25 | enum 26 | { 27 | idMenuQuit = 1000, 28 | idMenuAbout, 29 | 30 | idMenueAboutAuthor, 31 | idMenuShowMotionInfo, // 菜单项 是否显示 鼠标信息 32 | 33 | idMenuBlueText, // 菜单项 设置为蓝色文本 34 | idMenuRedText, // 菜单项 设置为红色文本 35 | idMenuGreenText // 菜单项 设置为绿色文本 36 | }; 37 | 38 | void OnClose(wxCloseEvent& event); 39 | void OnQuit(wxCommandEvent& event); 40 | 41 | void OnMotion(wxMouseEvent& event); // 鼠标移动事件响应函数 42 | void OnPaint(wxPaintEvent& event); // 窗口客户区绘图事件响应函数 43 | 44 | void OnAbout(wxCommandEvent& event); 45 | void OnAboutAuthor(wxCommandEvent& event); // 关于作者 46 | 47 | void OnTextColorSelected(wxCommandEvent& event); // 处理选中文本颜色 48 | 49 | int xPos, yPos; 50 | int selectedColorMenuItemId = idMenuBlueText; 51 | 52 | DECLARE_EVENT_TABLE() 53 | }; 54 | 55 | 56 | #endif // HELLOMYFRAMEMAIN_H 57 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.3/HelloMyFrame/resource.rc: -------------------------------------------------------------------------------- 1 | aaaa ICON "wx/msw/std.ico" 2 | 3 | #include "wx/msw/wx.rc" 4 | -------------------------------------------------------------------------------- /11-GUI/11.3-wxWidgets/11.3.3/readme.txt: -------------------------------------------------------------------------------- 1 | wxWidgets项目概貌分析 -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/HelloMenu/HelloMenu.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 92 | 93 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/HelloMenu/HelloMenuApp.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloMenuApp.cpp 3 | * Purpose: Code for Application Class 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2024-04-11 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifdef WX_PRECOMP 11 | #include "wx_pch.h" 12 | #endif 13 | 14 | #ifdef __BORLANDC__ 15 | #pragma hdrstop 16 | #endif //__BORLANDC__ 17 | 18 | #include "HelloMenuApp.h" 19 | #include "HelloMenuMain.h" 20 | 21 | IMPLEMENT_APP(HelloMenuApp); 22 | 23 | bool HelloMenuApp::OnInit() 24 | { 25 | HelloMenuFrame* frame = new HelloMenuFrame(0L, _("wxWidgets Application Template")); 26 | frame->SetIcon(wxICON(aaaa)); // To Set App Icon 27 | frame->Show(); 28 | 29 | return true; 30 | } 31 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/HelloMenu/HelloMenuApp.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloMenuApp.h 3 | * Purpose: Defines Application Class 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2024-04-11 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOMENUAPP_H 11 | #define HELLOMENUAPP_H 12 | 13 | #include 14 | 15 | class HelloMenuApp : public wxApp 16 | { 17 | public: 18 | virtual bool OnInit(); 19 | }; 20 | 21 | #endif // HELLOMENUAPP_H 22 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/HelloMenu/HelloMenuMain.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloMenuMain.cpp 3 | * Purpose: Code for Application Frame 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2024-04-11 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifdef WX_PRECOMP 11 | #include "wx_pch.h" 12 | #endif 13 | 14 | #ifdef __BORLANDC__ 15 | #pragma hdrstop 16 | #endif //__BORLANDC__ 17 | 18 | #include "HelloMenuMain.h" 19 | 20 | //helper functions 21 | enum wxbuildinfoformat { 22 | short_f, long_f }; 23 | 24 | wxString wxbuildinfo(wxbuildinfoformat format) 25 | { 26 | wxString wxbuild(wxVERSION_STRING); 27 | 28 | if (format == long_f ) 29 | { 30 | #if defined(__WXMSW__) 31 | wxbuild << _T("-Windows"); 32 | #elif defined(__WXMAC__) 33 | wxbuild << _T("-Mac"); 34 | #elif defined(__UNIX__) 35 | wxbuild << _T("-Linux"); 36 | #endif 37 | 38 | #if wxUSE_UNICODE 39 | wxbuild << _T("-Unicode build"); 40 | #else 41 | wxbuild << _T("-ANSI build"); 42 | #endif // wxUSE_UNICODE 43 | } 44 | 45 | return wxbuild; 46 | } 47 | 48 | BEGIN_EVENT_TABLE(HelloMenuFrame, wxFrame) 49 | EVT_CLOSE(HelloMenuFrame::OnClose) 50 | 51 | EVT_PAINT(HelloMenuFrame::OnPaint) 52 | EVT_MOTION(HelloMenuFrame::OnMontion) 53 | 54 | EVT_MENU(idMenuQuit, HelloMenuFrame::OnQuit) 55 | EVT_MENU(idMenuAbout, HelloMenuFrame::OnAbout) 56 | EVT_MENU(idMenuAboutAuthor, HelloMenuFrame::OnAboutAuthor) 57 | EVT_MENU(idMenuBlueText, HelloMenuFrame::OnTextColorSelected) 58 | EVT_MENU(idMenuRedText, HelloMenuFrame::OnTextColorSelected) 59 | 60 | END_EVENT_TABLE() 61 | 62 | HelloMenuFrame::HelloMenuFrame(wxFrame *frame, const wxString& title) 63 | : wxFrame(frame, -1, title) 64 | { 65 | #if wxUSE_MENUS && 1 66 | // create a menu bar 67 | wxMenuBar* mbar = new wxMenuBar(); 68 | wxMenu* fileMenu = new wxMenu(_T("")); 69 | fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application")); 70 | mbar->Append(fileMenu, _("&File")); 71 | 72 | wxMenu* optionsMenu = new wxMenu(_T("")); 73 | optionsMenu->AppendCheckItem(idMenuShowMotionInfo, _("&Show motion info"), _("Show motion info or no")); 74 | mbar->Append(optionsMenu, _("&Options")); 75 | 76 | optionsMenu->AppendSeparator(); 77 | 78 | optionsMenu->AppendRadioItem(idMenuBlueText, _("&Blue text"), _("Set text blue")); 79 | optionsMenu->AppendRadioItem(idMenuRedText, _("&Red text"), _("Set text red")); 80 | 81 | optionsMenu->AppendSeparator(); 82 | 83 | optionsMenu->AppendRadioItem(idMenuBlueText+99, _("&Big text"), _("Set text big")); 84 | optionsMenu->AppendRadioItem(idMenuRedText+100, _("&Small text"), _("Set text small")); 85 | 86 | wxMenu* helpMenu = new wxMenu(_T("")); 87 | helpMenu->Append(idMenuAbout, _("&About\tF1"), _("Show info about this application")); 88 | helpMenu->Append(idMenuAboutAuthor, _("About autho&r"), _("Show info about author")); // 添加菜单项 89 | mbar->Append(helpMenu, _("&Help")); 90 | 91 | SetMenuBar(mbar); 92 | #endif // wxUSE_MENUS 93 | 94 | #if wxUSE_STATUSBAR 95 | // create a status bar with some information about the used wxWidgets version 96 | CreateStatusBar(2); 97 | SetStatusText(_("Hello Code::Blocks user!"),0); 98 | SetStatusText(wxbuildinfo(short_f), 1); 99 | #endif // wxUSE_STATUSBAR 100 | 101 | } 102 | 103 | 104 | HelloMenuFrame::~HelloMenuFrame() 105 | { 106 | } 107 | 108 | void HelloMenuFrame::OnClose(wxCloseEvent &event) 109 | { 110 | Destroy(); 111 | } 112 | 113 | void HelloMenuFrame::OnQuit(wxCommandEvent &event) 114 | { 115 | Destroy(); 116 | } 117 | 118 | void HelloMenuFrame::OnAbout(wxCommandEvent &event) 119 | { 120 | wxString msg = wxbuildinfo(long_f); 121 | wxMessageBox(msg, _("Welcome to...")); 122 | } 123 | 124 | void HelloMenuFrame::OnAboutAuthor(wxCommandEvent& event) 125 | { 126 | wxString msg = wxT("关于作者南郁:帅气、智慧、没钱。"); 127 | wxMessageBox(msg, _("About author")); // 弹出消息框,第2入参是标题 128 | } 129 | 130 | void HelloMenuFrame::OnMontion(wxMouseEvent& event) 131 | { 132 | xPos = event.GetPosition().x; 133 | yPos = event.GetPosition().y; 134 | 135 | this->Refresh(); 136 | } 137 | 138 | void HelloMenuFrame::OnPaint(wxPaintEvent& event) 139 | { 140 | bool showMotionInfo = this->GetMenuBar()->IsChecked(idMenuShowMotionInfo); 141 | 142 | wxString txt; 143 | wxPaintDC dc(this); 144 | 145 | wxColour const* txtColor = (selectedColorId == idMenuBlueText)? wxBLUE : wxRED; 146 | dc.SetTextForeground(*txtColor); 147 | 148 | if (showMotionInfo) 149 | { 150 | txt << wxT("鼠标坐标:") << xPos << wxT(" - ") << yPos; 151 | } 152 | else 153 | { 154 | txt = wxT("你可以选中\"Show motion info\" 来显示鼠标位置信息"); 155 | } 156 | 157 | wxPoint pos (xPos + 10, yPos + 10); 158 | dc.DrawText(txt, pos); 159 | } 160 | 161 | void HelloMenuFrame::OnTextColorSelected(wxCommandEvent& event) 162 | { 163 | selectedColorId = event.GetId(); 164 | } 165 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/HelloMenu/HelloMenuMain.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: HelloMenuMain.h 3 | * Purpose: Defines Application Frame 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2024-04-11 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef HELLOMENUMAIN_H 11 | #define HELLOMENUMAIN_H 12 | 13 | #ifndef WX_PRECOMP 14 | #include 15 | #endif 16 | 17 | #include "HelloMenuApp.h" 18 | 19 | class HelloMenuFrame: public wxFrame 20 | { 21 | public: 22 | HelloMenuFrame(wxFrame *frame, const wxString& title); 23 | ~HelloMenuFrame(); 24 | private: 25 | enum 26 | { 27 | idMenuQuit = 1000, 28 | idMenuAbout, 29 | idMenuAboutAuthor, // 关于作者 30 | 31 | idMenuShowMotionInfo, // 是否显示鼠标位置 32 | 33 | idMenuBlueText, // 设置蓝色文本 34 | idMenuRedText, // 设置红色文本 35 | }; 36 | void OnClose(wxCloseEvent& event); 37 | void OnQuit(wxCommandEvent& event); 38 | void OnAbout(wxCommandEvent& event); 39 | void OnAboutAuthor(wxCommandEvent& event); // “关于作者” 菜单项事件响应函数 40 | 41 | void OnMontion(wxMouseEvent& event); // 鼠标移动事件响应函数 42 | void OnPaint(wxPaintEvent& event); // 窗口绘图事件响应函数 43 | void OnTextColorSelected(wxCommandEvent& event); // 设置文本颜色事件响应函数 44 | 45 | int xPos, yPos; 46 | int selectedColorId = idMenuBlueText; 47 | 48 | DECLARE_EVENT_TABLE() 49 | }; 50 | 51 | 52 | #endif // HELLOMENUMAIN_H 53 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/HelloMenu/resource.rc: -------------------------------------------------------------------------------- 1 | aaaa ICON "wx/msw/std.ico" 2 | 3 | #include "wx/msw/wx.rc" 4 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/Ls11/Ls11.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 94 | 95 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/Ls11/Ls11App.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Ls11App.cpp 3 | * Purpose: Code for Application Class 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2024-04-14 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifdef WX_PRECOMP 11 | #include "wx_pch.h" 12 | #endif 13 | 14 | #ifdef __BORLANDC__ 15 | #pragma hdrstop 16 | #endif //__BORLANDC__ 17 | 18 | #include "Ls11App.h" 19 | #include "Ls11Main.h" 20 | 21 | IMPLEMENT_APP(Ls11App); 22 | 23 | bool Ls11App::OnInit() 24 | { 25 | Ls11Frame* frame = new Ls11Frame(0L, _("wxWidgets Application Template")); 26 | frame->SetIcon(wxICON(aaaa)); // To Set App Icon 27 | frame->Show(); 28 | 29 | return true; 30 | } 31 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/Ls11/Ls11App.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Ls11App.h 3 | * Purpose: Defines Application Class 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2024-04-14 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef LS11APP_H 11 | #define LS11APP_H 12 | 13 | #include 14 | 15 | class Ls11App : public wxApp 16 | { 17 | public: 18 | virtual bool OnInit(); 19 | }; 20 | 21 | #endif // LS11APP_H 22 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/Ls11/Ls11Main.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Ls11Main.h 3 | * Purpose: Defines Application Frame 4 | * Author: d2school (nanyu@d2school.com) 5 | * Created: 2024-04-14 6 | * Copyright: d2school (www.d2school) 7 | * License: 8 | **************************************************************/ 9 | 10 | #ifndef LS11MAIN_H 11 | #define LS11MAIN_H 12 | 13 | #ifndef WX_PRECOMP 14 | #include 15 | #endif 16 | 17 | #include "Ls11App.h" 18 | 19 | class Ls11Frame: public wxFrame 20 | { 21 | public: 22 | Ls11Frame(wxFrame *frame, const wxString& title); 23 | ~Ls11Frame(); 24 | private: 25 | enum 26 | { 27 | idMenuQuit = 1000, 28 | idMenuAbout, 29 | 30 | idMenuAboutAuthor, // 关于作者 31 | idMenuShowMotionInfo, // 是否显示鼠标位置信息 32 | 33 | idMenuBlueColor, // 蓝色 34 | idMenuRedColor, // 红色 35 | idMenuGreenColor, // 绿色 36 | 37 | idMenuBigFont, // 大字体 38 | idMenuSmallFont // 小字体 39 | }; 40 | 41 | void OnClose(wxCloseEvent& event); 42 | void OnQuit(wxCommandEvent& event); 43 | void OnAbout(wxCommandEvent& event); 44 | void OnAboutAuthor(wxCommandEvent& event); 45 | 46 | // 鼠标移动事件响应函数 47 | void OnMotion(wxMouseEvent& event); 48 | // 窗口客户区绘图事件响应函数 49 | void OnPaint(wxPaintEvent& event); 50 | 51 | // 选择颜色的菜单项共用的事件响应函数 52 | void OnTextColorSelected(wxCommandEvent& event); 53 | 54 | // 选择字体(大小)的菜单项共用的事件响应函数 55 | void OnTextFontSelected(wxCommandEvent& event); 56 | 57 | int xPos, yPos; // 用于记住当前鼠标坐标 58 | int selectedColorMenutItemId = idMenuBlueColor; // 记录当前用户选中哪一个“颜色”菜单项 59 | int selectedFontMenuItemId = idMenuBigFont; // 默认大字体 60 | 61 | DECLARE_EVENT_TABLE() 62 | }; 63 | 64 | 65 | #endif // LS11MAIN_H 66 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/Ls11/resource.rc: -------------------------------------------------------------------------------- 1 | aaaa ICON "wx/msw/std.ico" 2 | 3 | #include "wx/msw/wx.rc" 4 | -------------------------------------------------------------------------------- /11-GUI/11.4-wxFrame/11.4.1-MainMenu/readme.txt: -------------------------------------------------------------------------------- 1 | HelloMenu - 11.4.1 主菜单 2 | 3 | Ls11 - 在HelloMenu的基础上,将其中设置字体大小的功能也实现了。 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 《白话C++》代码 2 | 3 | ## 正确配置IDE的文件编码识别机制 4 | 5 | 代码均以Code::Blocks的工程进行组织,并在Windows写成。不少代码中含有汉字,典型的如代码中一些注释。为避免Code::Blocks打开源代码时,将汉字显示成乱码,请在Windows下对Code::Blocks作如下配置。 6 | 7 | 点击 Code::Blocks主菜单:“Setting” -> “Editor” 。然后按下图进行设置。 8 | 9 | ![Code::Blocks的文件编码识别设置](http://image.d2school.com/img/github/bhcpp/codeblocks_file_encoding_set_for_bhcpp.jpg) 10 | 11 | ## 目录组织说明 12 | 13 | 1. 第1层为章。比如:03-feelling-1 表示:第3章,《感受一》 14 | 2. 第2层为章节。比如:3.10.3-HelloOOVirtual 表示:第 3.10.3 小节。 15 | 3. 章节后如果还接有 -N,其中N为整数,表示该小节内相关代码的第N个教学演进版本(而非指该小节下的第几点)。比如:3.11.5-2-HelloOOEncapsulation。表示第3.11.5小节中,有关“封装应用示例” 代码的第2个演进版本。 16 | --------------------------------------------------------------------------------