title: c++ call class function as callback
body: <p>I want to call a class function as callback for my timer but it is fixing out. Next way i try to do is copy a function pointer to another cpp file within the project so someone tell me what is wrong in this.</p>
  
  <p>Header Include File Program:</p>
  
  <pre><code>class Progc:
  
  public IStorage
  {
  
  public:
  Processor(HWND Hwnd);
  static void CALLBACK ClickCall(HWND hwnd, UINT uMsg, UINT timerId, DWORD dwTime);
  
  };
  </code></pre>
  
  <p>Timecatch.cpp file Program </p>
  
  <pre><code>void CALLBACK Progc::ClickCall(HWND hwnd, UINT uMsg, UINT timerId,   DWORD dwTime)
  {
      RECT rcOwner; 
      GetWindowRect(hwnd, &amp;rcOwner);
      SetCursorPos((rcOwner.top), (rcOwner.left));
  
  
      this-&gt;Action();
      KillTimer(hwnd, 0); 
  }
  </code></pre>
  
  <p>The error i get above is </p>
  
  <pre><code>error C2671: 'Progc::ClickCall' : static member functions do not have 'this' pointers
  error C2227: left of '-&gt;Action' must point to class/struct/union/generic type
  </code></pre>
  
  <p>Continue of Timecatch.cpp file Program</p>
  
  <pre><code>void Progc::Action()
  {
      SetTimer(hWndParent, 0, 6000,(TIMERPROC) &amp;this-&gt;ClickCall);   
  }
  </code></pre>
  
  <p>Next is another file program file name Program.cpp</p>
  
  <pre><code>Progc *ProgBr1;
  ProgBr1 = new Processor(hWnd);
  </code></pre>
  
  <p>What i want to do is simple, i want to make <code>Action()</code> function call from <code>ClickCall(....)</code> Function after the timer call that function, either with other way or by using ProgBr1 pointer like i use ProgBr1 to call Action from Program.cpp.</p>
  
  <pre><code>ProgBr1-&gt;Action();
  </code></pre>
  
  <p>But i cannot make intialize another variable and get pointer with</p>
  
  <pre><code>ProgBr1 = new Processor(hWnd);
  </code></pre>
  
  <p>So is there any way to make another pointer data and copy ProgBr1 value to it and use it in Timecatch.cpp file?</p>
  
  <p>Really confused and new to c++. Will post here if i get any update.</p>