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.
Nothing stops you from using boost in a wxWidgets app. You just need to make sure the handler code is executed from the main thread if it accesses GUI elements.
doublemax wrote: ↑Mon May 31, 2021 4:19 pm
Nothing stops you from using boost in a wxWidgets app. You just need to make sure the handler code is executed from the main thread if it accesses GUI elements.
That's the fallback plan. But I'm now really curious: Is there a clean way to deal with a varying number of wxTimers? The idea I was just investigating was to use wxTimerEvent::GetTimer() and then call Detroy() on the wxTimer, but apparently there is no wxTimer::Detroy() method.
doublemax wrote: ↑Wed Jun 02, 2021 8:32 am
Looks fine to me. The SetOwner() call is probably not needed, as you're binding the event handler to the timer anyway.
Thanks. I just made the constructor private to guarantee that the timer is created via new. Otherwise wxTheApp->ScheduleForDestruction() might be called with a static or stack instance which is probably bad.
Hello,
Will the timers be all calling the same function? If so, an easy way to handle this is to use and event table macro to bind the function to the event and just setting the same ID for all timers you need. Then, if you have 100 timers but all with the same ID, they'll all call the same function when they fire. But I see you've already figured out another way to handle it.
Oh, btw, you should consider passing the events by reference in your event handlers ('wxTimerEvent& event' instead of 'wxTimerEvent event'). Don't know if you did it on purpose but I don't see why you would copy the event every time the function gets called.
AmadeusK525 wrote: ↑Wed Jun 02, 2021 12:53 pm
Hello,
Will the timers be all calling the same function? If so, an easy way to handle this is to use and event table macro to bind the function to the event and just setting the same ID for all timers you need. Then, if you have 100 timers but all with the same ID, they'll all call the same function when they fire. But I see you've already figured out another way to handle it.
Oh, btw, you should consider passing the events by reference in your event handlers ('wxTimerEvent& event' instead of 'wxTimerEvent event'). Don't know if you did it on purpose but I don't see why you would copy the event every time the function gets called.
AmadeusK525 wrote: ↑Wed Jun 02, 2021 12:53 pm
Oh, btw, you should consider passing the events by reference in your event handlers ('wxTimerEvent& event' instead of 'wxTimerEvent event'). Don't know if you did it on purpose but I don't see why you would copy the event every time the function gets called.