wxMenu的一个demo

 我这里写的东西很简单,就是一个应用wxMenu的Demo

如何配置环境请参考     配置cdt下wxwidgets编程

就两个文件 wxMenuStudio.h 和wxMenuStudio.cpp

wxMenuStudio.h

#ifndef WXMENUSTUDIO_H_
#define WXMENUSTUDIO_H_

class wxMenuStudio : public wxApp
{
public:
    bool OnInit();   
};

class wxMenuFrame : public wxFrame
{
public:

    wxMenuFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
            const wxPoint& pos, const wxSize& size, const long style);
    ~wxMenuFrame();
    void OnAbout(wxCommandEvent& event);
    void OnCopyRight(wxCommandEvent& event);
private:
    DECLARE_EVENT_TABLE()
};

#endif /*WXMENUSTUDIO_H_*/





wxMenuStudio.cpp

#include
#include "wxMenuStudio.h"
#include "wx/aboutdlg.h"

IMPLEMENT_APP(wxMenuStudio)

enum
{
    ID_ABOUT=1,
    ID_COPYRIGHT
};

BEGIN_EVENT_TABLE(wxMenuFrame,wxFrame)
    EVT_MENU(ID_ABOUT,wxMenuFrame::OnAbout)
    EVT_MENU(ID_COPYRIGHT,wxMenuFrame::OnCopyRight)
END_EVENT_TABLE()

bool wxMenuStudio::OnInit()
{
    wxMenuFrame* frame = new wxMenuFrame((wxWindow*)NULL,wxID_ANY,_T("Menu Demo"),
            wxDefaultPosition,wxSize(500, 400),wxDEFAULT_FRAME_STYLE);
    frame->Show(true);
    return true;
}

wxMenuFrame::wxMenuFrame(wxWindow * parent,
                        const wxWindowID id,
                        const wxString& title,
                        const wxPoint& pos,
                        const wxSize& size,
                        const long style)
    : wxFrame(parent,id,title,pos,size,style)
{
    wxMenu* help = new wxMenu();
    help->Append(ID_ABOUT,_T("About"));
    help->Append(ID_COPYRIGHT,_T("CopyRight"));
    wxMenuBar* menu = new wxMenuBar;
    menu->Append(help,"Help");
    this->SetMenuBar(menu);
}

wxMenuFrame::~wxMenuFrame()
{
}

void wxMenuFrame::OnAbout(wxCommandEvent& event)
{
    ::wxMessageBox("wxMenu Demo","关于");
}

void wxMenuFrame::OnCopyRight(wxCommandEvent& event)
{
    wxMessageBox("kese设计","版权信息");
}

你可能感兴趣的:(学习wxWidgets,menu,table,class,编程,null)