C++ Call non static function on another function

Pages: 12
Up...
Well, there are several Threats, and each is assigned a different value
What's the idea behind setting just one value to the progress bar (that's what it actually is) every thread?

EDIT: More elaborated example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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");
}
Last edited on
Topic archived. No new replies allowed.
Pages: 12