zoukankan      html  css  js  c++  java
  • 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!"));
    }
    

      

  • 相关阅读:
    C# 串口通信总结
    客户端下载文件和服务器端下载文件总结
    Android 上传图片到 Asp.Net 服务器的问题
    iOS内存泄漏自动检测工具PLeakSniffer
    让iOS开发变得更有效率-分类、工具类
    分分钟解决iOS开发中App启动广告的功能
    响应者链及相关机制总结
    stackoverflow上关于iOS的票数最多(最常见)的15个问题
    iOS 开发之 ReactiveCocoa(进阶)
    iOS 开发之 ReactiveCocoa(基础)
  • 原文地址:https://www.cnblogs.com/wucg/p/2199197.html
Copyright © 2011-2022 走看看