• First wxWidgets Demo, wxWidgets简单示例


    windows下,注意文件格式设为UTF-8。

    Code::Blocks 10.05设置: Setting -> Editor

    Main.cpp:

    #include "wx/wx.h"
    //Declare the application class
    class MyApp:public wxApp{
    public:
        //Called on application startup
        virtual bool OnInit();
    };
    // Declare our main frameclass
    class MyFrame:public wxFrame{
    public:
        // Constructor
        MyFrame(const wxString& title);
        // Event handlers
        void OnQuit(wxCommandEvent& event);
        void OnAbout(wxCommandEvent& event);
    private:
        // This class handles events
        DECLARE_EVENT_TABLE();
    };
    // Implements MyApp& GetApp()
    DECLARE_APP(MyApp)
    // Give wxWidgets the means to create a MyApp object
    IMPLEMENT_APP(MyApp)
    
    // Initialize the application
    bool MyApp::OnInit(){
        // Create the main application window
        MyFrame *frame=new MyFrame(wxT("Minimal wxwidgets App"));
        // Show it
        frame->Show(true);
        // Start the event loop
        return true;
    }
    // Event table for MyFrame
    BEGIN_EVENT_TABLE(MyFrame,wxFrame)
        EVT_MENU(wxID_ABOUT,MyFrame::OnAbout)
        EVT_MENU(wxID_EXIT,MyFrame::OnQuit)
    END_EVENT_TABLE()
    
    void MyFrame::OnAbout(wxCommandEvent& event){
    
        wxString msg;
        msg.Printf(wxT("您好,Hello and welcome to %s"),wxVERSION_STRING);
        wxMessageBox(msg,wxT("About Minimal"),
                     wxOK | wxICON_INFORMATION,this);
    }
    
    void MyFrame::OnQuit(wxCommandEvent& event){
        // Destroy the frame
        Close();
    }
    
    //#include "mondrian.xpm"
    
    MyFrame::MyFrame(const wxString& title):
        wxFrame(NULL,wxID_ANY,title){
        //SetIcon(wxIcon(mondrian_xpm));
        wxMenu *fileMenu=new wxMenu;
        wxMenu *helpMenu=new wxMenu;
        helpMenu->Append(wxID_ABOUT,wxT("&About...\tF1"),
                         wxT("Show About dialog"));
        fileMenu->Append(wxID_EXIT,wxT("E&xit\tAlt-X"),
                         wxT("Quit this program退出程序"));
        wxMenuBar *menuBar=new wxMenuBar();
        menuBar->Append(fileMenu,wxT("&File"));
        menuBar->Append(helpMenu,wxT("&Help"));
        SetMenuBar(menuBar);
        CreateStatusBar(2);
        SetStatusText(wxT("中国人Welcome to wxwidgets!"));
    }
    

      

  • 相关阅读:
    java垃圾回收机制
    mysql的find_in_set函数操作
    mysql中常见的sql语句语法书写操作
    如何破坏双亲委派原则
    mysql中临时表的创建
    spring当中的事务处理
    restTemplate调用操作出现乱码
    mysql中的any_value的基本使用操作
    DTD与XSD的区别
    idea的插件
  • 原文地址:https://www.cnblogs.com/wucg/p/2199197.html
Copyright © 2020-2023  润新知