title: C++ Changing HWND Window Procedure in runtime
body: <p>I'm working in an IDE which creates a <code>hwnd</code> and its respective <code>WndProc</code> <code>LRESULT CALLBACK</code>. I need to change the <code>WndProc</code> to a custom one.</p>
  
  <p>I've read that <code>SetWindowLong</code> would do the job but I can't find any working example. For example:</p>
  
  <p><code>HWND hwnd; //My window</code></p>
  
  <p><code>SetWindowLong(hwnd, GWL_WNDPROC, myNewWndProc);</code></p>
  
  <p>Third parameter for <code>SetWindowLong</code> is a <code>Long</code> as the name of the function names it. How can I make a reference from my <code>WndProc</code> function to a <code>Long</code>?</p>
  
  <p>My <code>WndProc</code>:</p>
  
  <pre><code>LRESULT CALLBACK WndProcedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
  
  msg_dev(toString(uMsg));
  
  switch(uMsg){
  
      case WM_MOUSEMOVE:
          SetCursor(LoadCursor(NULL, IDC_HAND));
          break;
  
      case WM_LBUTTONDOWN:
          msg_dev("Button down!");
          break;
  
      default:
          DefWindowProc(hwnd, uMsg, wParam, lParam);
  }
  
  return 0;
  };
  </code></pre>