注意生成控制台程序,即-L/SUBSYSTEM:console
1 //This application demonstrates how to show a dialog in a console app. 2 3 #include <wx/wx.h> 4 5 #include <stdio.h> 6 7 class MyApp : public wxApp 8 { 9 10 public: 11 bool OnInit (); 12 int OnExit(); 13 int OnRun(); 14 15 }; 16 17 18 bool MyApp::OnInit() 19 { 20 21 return true; 22 23 } 24 int MyApp::OnExit() 25 { 26 return 0; 27 } 28 29 30 //all you want to do do it here: 31 int MyApp::OnRun() 32 { 33 wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program"); 34 printf("This is a line of text from console.\n"); 35 wxPrintf("Press any key to show a dialog..\n"); 36 system("pause"); 37 38 wxMessageBox(wxT("This is a window.")); 39 40 wxPrintf("Press any key to continue...\n"); 41 system("pause"); 42 43 wxPrintf("This is a line of text from console using wxPrintf\n"); 44 system("pause"); 45 return 0; 46 } 47 int main(int argc,char* argv[]) 48 { 49 wxInitializer init; 50 if(!init) 51 { 52 fprintf(stderr,"failed to init wx.abort.\n"); 53 return -1; 54 } 55 MyApp* app=new MyApp(); 56 57 wxApp::SetInstance(app); 58 59 //nothing need to write here. 60 61 62 return wxEntry(argc,argv); 63 64 }
Console 应用程序中使用wxMessageBox,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/godspeedsam/p/3854067.html