Hey I'm trying to make a simple GUI with tabs that handle thier own events, I have made a class that will represent each tab and all its controls, the controls are then added to a panel member of that class and then the panel is added to the notebook, to handle events I'm using connect to add a function that is a member of the class that I made to the panels events, I have tested it and it works, when I click a button I get a message box popping up So I know it works, The problem is, If i try to access a variable of the class I made in the event handler function it will compile but there will be a run time error. I have made the members public that I which to access and tried everything I can but for some reason it won't work. Here is basically what I have.
class.h
Code: Select all
class myTabClass : public wxEvtHandler
{
public:
myTabClass(wxWindow *notebook);
~myTabClass();
wxButton *testBtn;
void btnFunction(wxCommandEvent &event);
wxPanel *panel;
int numToIterate;
wxWindowID id;
};
class.cpp
Code: Select all
myTabClass::myTabClass(wxWindow *notebook)
{
id = 4001;
panel = new panel(notebook);
testBtn = new wxButton(panel,id,wxT("test"));
panel->Connect(id,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(myTabClass::btnFunction));
numToIterate = 1;
}
void myTabClass::btnFunction(wxCommandEvent &event)
{
this->numToIterate++;
}
myTabClass::~myTabClass()
{
}
What the problem seems to be is that when its tries to access numToIterator to add to it, it can't find it, I'm not sure how I can solve this problem so that it works. Any help would be great. Thanks in advanced.[/code]