Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8304287
  • 博文数量: 1413
  • 博客积分: 11128
  • 博客等级: 上将
  • 技术积分: 14685
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-13 10:03
个人简介

follow my heart...

文章分类

全部博文(1413)

文章存档

2013年(1)

2012年(5)

2011年(45)

2010年(176)

2009年(148)

2008年(190)

2007年(293)

2006年(555)

分类: C/C++

2006-08-25 16:33:06

[base.h]
#ifndef __BASE_H
#define __BASE_H

class MainApp: public wxApp
{
  public:
      virtual bool OnInit();
};

class MainFrame: public wxFrame
{
  public:
      MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size);
      void OnQuit(wxCommandEvent &event);
      void OnAbout(wxCommandEvent &event);
  private:
      DECLARE_EVENT_TABLE()
};

enum
{
   ID_MAINWIN_QUIT = wxID_HIGHEST+1,
   ID_MAINWIN_ABOUT = wxID_HIGHEST+2
};


#endif

[base.cpp]
#include
#ifndef WX_PRECOMP
   #include
#endif

#include "base.h"

IMPLEMENT_APP(MainApp)

bool MainApp::OnInit()
{
   MainFrame *win = new MainFrame(_("Frame"), wxPoint (100, 100),
     wxSize(450, 340));
   win->Show(TRUE);
   SetTopWindow(win);

   return TRUE;
}


BEGIN_EVENT_TABLE(MainFrame, wxFrame)
   EVT_MENU(ID_MAINWIN_QUIT, MainFrame::OnQuit)
   EVT_MENU(ID_MAINWIN_ABOUT,MainFrame::OnAbout)
END_EVENT_TABLE()

MainFrame::MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
    : wxFrame((wxFrame *) NULL, -1, title, pos, size)
{
    wxMenu *FileMenu = new wxMenu;
    wxMenuBar *MenuBar = new wxMenuBar;

    FileMenu->Append(ID_MAINWIN_QUIT, _("&Quit"));
    FileMenu->Append(ID_MAINWIN_ABOUT,_("&About"));

    MenuBar->Append(FileMenu, _("&File"));
    SetMenuBar(MenuBar);

    CreateStatusBar(2);
    SetStatusText(_("Hello World!"));
}

void MainFrame::OnQuit(wxCommandEvent & WXUNUSED(event))
{
    Close(TRUE);
}

void MainFrame::OnAbout(wxCommandEvent & WXUNUSED(event))
{
    wxMessageBox(_("love make the world go around!"),_("important:"),wxOK,this);
}

阅读(2487) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~