title: How do I `std::bind` a non-static class member to a Win32 callback function `WNDPROC`?
body: <p>I'm trying to bind a non-static class member to a standard <a href="http://msdn.microsoft.com/en-us/library/ms633573.aspx" rel="noreferrer"><code>WNDPROC</code></a> function. I know I can simply do this by making the class member static. But, as a C++11 STL learner, I'm very interested in doing it by using the tools under the <code>&lt;functional&gt;</code> header.</p>
  
  <p>My code is as follows.</p>
  
  <pre><code>class MainWindow
  {
      public:
          void Create()
          {
              WNDCLASSEXW WindowClass;
              WindowClass.cbSize          = sizeof(WNDCLASSEX);
              WindowClass.style           = m_ClassStyles;
              WindowClass.lpfnWndProc     = std::function&lt;LRESULT(HWND, UINT, WPARAM, LPARAM)&gt;
                                              (   std::bind(&amp;MainWindow::WindowProc, 
                                                  *this,
                                                  std::placeholders::_1,
                                                  std::placeholders::_2,
                                                  std::placeholders::_3,
                                                  std::placeholders::_4));
              WindowClass.cbClsExtra      = 0;
              WindowClass.cbWndExtra      = 0;
              WindowClass.hInstance       = m_hInstance;
              WindowClass.hIcon           = LoadIconW(m_hInstance, MAKEINTRESOURCEW(IDI_WINDOW));
              WindowClass.hCursor         = LoadCursor(NULL, IDC_ARROW);
              WindowClass.hbrBackground   = (HBRUSH) COLOR_WINDOW;
              WindowClass.lpszMenuName    = MAKEINTRESOURCEW(IDR_MENU);
              WindowClass.lpszClassName   = m_ClassName.c_str();
              WindowClass.hIconSm         = LoadIconW(m_hInstance, MAKEINTRESOURCEW(IDI_WINDOW_SMALL));
              RegisterClassExW(&amp;WindowClass);
              m_hWnd = CreateWindowEx(/*_In_      DWORD*/     ExtendedStyles,
                                      /*_In_opt_  LPCTSTR*/   m_ClassName.c_str(),
                                      /*_In_opt_  LPCTSTR*/   m_WindowTitle.c_str(),
                                      /*_In_      DWORD*/     m_Styles,
                                      /*_In_      int*/       m_x,
                                      /*_In_      int*/       m_y,
                                      /*_In_      int*/       m_Width,
                                      /*_In_      int*/       m_Height,
                                      /*_In_opt_  HWND*/      HWND_DESKTOP,
                                      /*_In_opt_  HMENU*/     NULL,
                                      /*_In_opt_  HINSTANCE*/ WindowClass.hInstance,
                                      /*_In_opt_  LPVOID*/    NULL);
  
          }
  
      private:
          LRESULT CALLBACK WindowProc(_In_ HWND hwnd,
                                      _In_ UINT uMsg,
                                      _In_ WPARAM wParam,
                                      _In_ LPARAM lParam)
          {
              return DefWindowProc(hwnd, uMsg, wParam, lParam);
          }
  };
  </code></pre>
  
  <p>When I run it as is, it gives the error message:</p>
  
  <pre><code>Error: no suitable conversion function from "std::function&lt;LRESULT(HWND, UINT, WPARAM, LPARAM)&gt;" to "WNDPROC".
  </code></pre>