Event table confusions..... was "confusion over members..."

Rory Walsh rorywalsh at ear.ie
Fri Nov 3 09:06:43 PST 2006


No I'm not using 'this' when calling loopStations member function. Here 
is the code, I've left out wxApp.cpp/.h, but I can include them if it 
helps, hope this is enough for you to spot what the problem is.

Rory.


//----------wxWidgets.h----------------------
#ifndef __WXWIDGETSFRAME_H
#define __WXWIDGETSFRAME_H
#include <wx/wx.h>

//=======================================================
class wxLoopStation : public wxMDIChildFrame
{
public:
wxLoopStation(wxMDIParentFrame* parent,
              wxWindowID id,
              const wxString& title,
              const wxPoint& pos,
              const wxSize& size);
virtual ~wxLoopStation();
wxPanel* panel;
wxTextCtrl* text;
wxButton* button;
void OnButton(wxCommandEvent &Event);
protected:
DECLARE_EVENT_TABLE()
};
//=======================================================

class wxWidgetsFrame : public wxMDIParentFrame
{
public:
wxWidgetsFrame(const wxString& title, const wxPoint& pos, const wxSize& 
size);
virtual ~wxWidgetsFrame();
void OnQuit(wxCommandEvent& event);
void OnNew(wxCommandEvent& event);
void OnTest(wxCommandEvent& event);
wxLoopStation* loopStation;
private:
DECLARE_CLASS(wxWidgetsFrame)
DECLARE_EVENT_TABLE()
};

#endif //__WXWIDGETSFRAME_H

//----------wxWidgetsFrame.cpp---------------
#include "wxWidgetsApp.h"
#include "wxWidgetsFrame.h"

enum
{
	ID_MENU_QUIT = 1,
	ID_NEW = 2,
	ID_TEST = 3,
	ID_BUTTON = 4
};
//event tables for wxWidgetsFrame and wxLoopStation
IMPLEMENT_CLASS(wxWidgetsFrame, wxFrame)
BEGIN_EVENT_TABLE(wxWidgetsFrame, wxMDIParentFrame)
	EVT_MENU(ID_MENU_QUIT,  wxWidgetsFrame::OnNew)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxLoopStation, wxMDIChildFrame)
	EVT_BUTTON (ID_BUTTON,  wxWidgetsFrame::OnTest)
END_EVENT_TABLE()

//*********************** main frame constructor***********************
wxWidgetsFrame::wxWidgetsFrame(const wxString& title, const wxPoint& 
pos, const wxSize& size)
: wxMDIParentFrame((wxMDIParentFrame *)NULL, -1, title, pos, size)
{

	wxMenu *fileMenu = new wxMenu(_(""), wxMENU_TEAROFF);
	fileMenu->Append(ID_MENU_QUIT, "New");
	fileMenu->Append(ID_TEST, "Test");

	wxMenuBar *menuBar = new wxMenuBar();
	menuBar->Append(fileMenu, _("&File"));
	SetMenuBar(menuBar);

}
//******************************************************************************
wxWidgetsFrame::~wxWidgetsFrame()
{
}
//******************************************************************************
void wxWidgetsFrame::OnNew(wxCommandEvent& event)
{
loopStation = new wxLoopStation(this, -1, "test", wxPoint(20, 20), 
wxSize(215, 255));
}
//******************************************************************************
void wxWidgetsFrame::OnTest(wxCommandEvent& event)
{
  wxMessageBox(loopStation->text->GetValue());
}
//******************************************************************************
void wxWidgetsFrame::OnQuit(wxCommandEvent& event)
{
	Close(TRUE);
}
//******* Constructor for wxLooperStation calss  ******************
wxLoopStation::wxLoopStation(wxMDIParentFrame* parent, wxWindowID id, 
const wxString& title, const wxPoint& pos, const wxSize& size)
: wxMDIChildFrame((wxMDIParentFrame*)parent, id, title, pos, size)
{
  wxPanel* panel = new wxPanel(this, -1, wxDefaultPosition, wxSize(100, 
60));
  text = new wxTextCtrl(panel, -1, "3",wxPoint(10, 10), wxSize(40, 20), 
wxTE_READONLY);
  button = new wxButton(panel, ID_BUTTON, "test button", wxPoint(50,20));
}
//******************************************************************************
wxLoopStation::~wxLoopStation()
{
}
//********************************************************************************




More information about the wx-users mailing list