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 <wx/wx_gch.h>
#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设计","版权信息");
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值