Hi! Check out this example:
#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 OnMouse( wxMouseEvent &event);
void OnQuit(wxCommandEvent &event);
private:
DECLARE_EVENT_TABLE()
};
enum
{
ID_MAINWIN_QUIT = wxID_HIGHEST+1
};
#endif
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#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_RIGHT_DOWN(MainFrame::OnMouse)
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");
MenuBar->Append(FileMenu, "&File");
SetMenuBar(MenuBar);
}
void MainFrame::OnMouse(wxMouseEvent &event)
{
wxMessageBox("You clicked the frame!");
}
void MainFrame::OnQuit(wxCommandEvent & WXUNUSED(event))
{
Close(TRUE);
}
upCASE ----------------------------------- If it was hard to write, it should be hard to read!- Do. Or do not. There is no try! |