Event table confusions..... was "confusion over members..."
Chad Wagner
chad at chadawagner.com
Fri Nov 3 09:18:53 PST 2006
I don't think loopStation is being initialized. Looking at your
event table declaration, is it your intent to have the OnNew method
called for an ID_MENU_QUIT event? Is anything being called for
ID_NEW event? I see the only place you initialize loopStation is in
OnNew, so I'm guessing it is never being called.
On Nov 3, 2006, at 12:06 PM, Rory Walsh wrote:
> 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()
> {
> }
> //
> **********************************************************************
> **********
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
More information about the wx-users
mailing list