class APPDlg
{
public:
APPDlg(wxWindow *const parent)
{
m_Timer.SetOwner(this); // This means that the timer event goes to 'OnTimer()'
Connect(wxID_ANY, wxEVT_TIMER, wxTimerEventHandler(CMain::OnTimer)); // This is the actual connection to 'OnTimer()'
m_Timer.Start(100, wxTIMER_CONTINUOUS); // This fires every 100 ms (10th of a second)
}
virtual ~APPDlg()
{
m_Timer.Stop(); // ends the timer
Disconnect(wxID_ANY, wxEVT_TIMER, wxTimerEventHandler(CMain::OnTimer)); // and disconnects
}
public:
void SetValue(int v) // To set the value in the thread
{
m_Value = v;
}
private:
void OnTimer(wxTimerEvent &evt) // Will _not_ be called externally
{
WxGauge1->SetValue(m_Value); // Update WxGauge1 (the progress bar)
}
private:
wxTimer m_Timer;
int m_Value
};
...
void Thread(void *p)
{
APPDlg *a = (APPDlg *) p;
a->SetValue(20);
system("start run.exe");
}