If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
So I'm trying to create a function that can create a new timer and auto bind events for it. The problem is that the timer only works within that function and not in the function/class which called it. You can uncomment the loop in "newtimer" an you can see the timer works fine until the end of the function.
void OnTimer(wxTimerEvent& event) //gets called each timer event
{
wxString writeout;
writeout.Printf("timer %i says hi", event.GetId());
wxMessageBox(writeout);
}
wxTimer* newtimer(wxEvtHandler *eventhandler, void (*the_function) (wxTimerEvent&) = NULL)
{
eventhandler->Bind(wxEVT_TIMER, the_function);
wxTimer m_timer(eventhandler);
m_timer.Start(2000);
/*
for (int x=0; x<10 ;x++)
{
Sleep(300);
wxYield();
}
*/
return &m_timer;
}
void MyDialog::OnButton5Click(wxCommandEvent& event)
{
wxTimer* m_timer = gauges.newtimer(this, OnTimer);
//does a few more file processing loops here
}
Any help would be appreciated. I also tried starting the timer again in OnButton5Click but still nothing... It's probably something obvious I'm sure, but I've been staring at code all day...