zoukankan      html  css  js  c++  java
  • Console 应用程序中使用wxMessageBox

    注意生成控制台程序,即-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.
    ");
    35     wxPrintf("Press any key to show a dialog..
    ");
    36     system("pause");
    37 
    38     wxMessageBox(wxT("This is a window."));
    39 
    40     wxPrintf("Press any key to continue...
    ");
    41     system("pause");
    42 
    43     wxPrintf("This is a line of text from console using wxPrintf
    ");
    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.
    ");
    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 }
  • 相关阅读:
    逻辑回归
    异常
    内部类
    接口
    多态
    final关键字(最终的)
    不能被继承的父类成员
    对象初始化的过程
    方法重写
    abstract关键字
  • 原文地址:https://www.cnblogs.com/godspeedsam/p/3854067.html
Copyright © 2011-2022 走看看