title: Call SetWindowsHookEx with method defined in header file
body: <p>I am attempting to add a low level mouse hook to a class.  I am able to do so by placing this function in my CPP file:</p>
  
  <pre><code>LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
  {
      //my hook code here
      return CallNextHookEx(0, nCode, wParam, lParam);
  } 
  </code></pre>
  
  <p>Then, I set up the hook in the class constructor like so:</p>
  
  <pre><code>HHOOK mousehook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, NULL, 0);
  </code></pre>
  
  <p>This works fine for intercepting mouse events, however since the callback function is not defined in my class, it does not have access to any of my class variables.  </p>
  
  <p>Therefore, I tried defining the callback function in my header file like so:</p>
  
  <pre><code>LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam);
  </code></pre>
  
  <p>and in my CPP file like this (TMainForm being the class):</p>
  
  <pre><code>LRESULT CALLBACK TMainForm::MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
  {
       //my hook code here
       return CallNextHookEx(0, nCode, wParam, lParam);
  }
  </code></pre>
  
  <p>However, when I attempt to compile like this, I get the following errors:</p>
  
  <p><code>[bcc32 Error] MainFormU.cpp(67): E2034 Cannot convert 'long (__stdcall * (_closure )(int,unsigned int,long))(int,unsigned int,long)' to 'long (__stdcall *)(int,unsigned int,long)'</code></p>
  
  <p><code>[bcc32 Error] MainFormU.cpp(67): E2342 Type mismatch in parameter 'lpfn' (wanted 'long (__stdcall *)(int,unsigned int,long)', got 'void')</code></p>
  
  <p>What exactly am I doing wrong here?  How is the method now different since I have made it a part of my <code>TMainForm</code> class?</p>