Hi! Have a look at this.
#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_MOUSE_EVENTS(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);
CreateStatusBar(1);
SetStatusText("Hello World!");
}
void MainFrame::OnMouse(wxMouseEvent &event)
{
if( event.IsButton() )
SetStatusText( wxString::Format("%d. button pressed",event.GetButton()));
else if(event.Moving())
SetStatusText("The mouse was moved...");
}
void MainFrame::OnQuit(wxCommandEvent & WXUNUSED(event))
{
Close(TRUE);
}
For questions: Post here or mail me in private.
upCASE ----------------------------------- If it was hard to write, it should be hard to read!- Do. Or do not. There is no try! |