title: Win32 - WndProc as class member, pointer to class instance is always nullptr
body: <p>I am trying to wrap WndProc as a private class member. I read the trick is to use two WndProc functions, one of them static. I set <code>cbWndExtra</code> to the size of a <code>LONG_PTR</code> and tried setting and getting the pointer to my class instance using <code>SetWindowLongPtr</code> and <code>GetWindowLongPtr</code>. I am then checking if it's a nullptr and calling the second WndProc if it's not. But for some reason <code>pApplication</code> always is a <code>nullptr</code> so my application is always running the <code>DefWindowProc</code> without running my own WndProc.</p>
  <p><strong>Application.h</strong></p>
  <pre><code>private:
      static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) noexcept;
      LRESULT HandleMsg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) noexcept;
  </code></pre>
  <p><strong>Application.cpp</strong></p>
  <pre><code>LRESULT CALLBACK Application::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) noexcept
  {
      Application* pApplication;
  
      if (msg == WM_NCCREATE)
      {
          pApplication = static_cast&lt;Application*&gt;(reinterpret_cast&lt;CREATESTRUCT*&gt;(lParam)-&gt;lpCreateParams);
          SetWindowLongPtr(hWnd, GWL_USERDATA, reinterpret_cast&lt;LONG_PTR&gt;(pApplication));
      }
      else
      {
          pApplication = reinterpret_cast&lt;Application*&gt;(GetWindowLongPtr(hWnd, GWL_USERDATA));
      }
  
      if (pApplication)
          return pApplication-&gt;HandleMsg(hWnd, msg, wParam, lParam);
  
      return DefWindowProc(hWnd, msg, wParam, lParam);
  }
  </code></pre>