title: Cannot interact with Window
body: <p>I have created a simple OpenGL renderer that runs on Windows. I have no problems creating the window and setting the rendering context. The problem occurs after the window has been setup. </p>
  
  <p>I cannot interact with the Window at all. If I mouse over anywhere on the Window, my cursor appears as a loading cursor. Here is the function I use to create the Window. Why is this happening?</p>
  
  <pre><code>bool BroGLWin::B_CreateWindow(int width, int height, int colorBits) {
  if (!classRegistered) {
      WNDCLASS wc;
  
      memset(&amp;wc, 0, sizeof(wc));
  
      wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
      wc.lpfnWndProc = (WNDPROC)wndproc;
      wc.cbClsExtra = 0;
      wc.cbWndExtra = sizeof(void*) + sizeof(int);
      wc.hInstance = GetModuleHandle(NULL);
      //wc.hIcon = LoadIcon(hinstOpenGL, MAKEINTRESOURCE(IDI_ICON1));
      wc.hCursor = LoadCursor(NULL, IDC_ARROW);
      wc.hbrBackground = NULL;
      wc.lpszMenuName = 0;
      wc.lpszClassName = WINDOW_CLASS_NAME;
  
      if (!RegisterClass(&amp;wc)) {
          // TODO: Add safe error here
          // unable to register class
      }
      classRegistered = true;
  }
  
  // create HWND
  if (!hWnd) {
      hWnd = CreateWindowEx(
          WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
          WINDOW_CLASS_NAME,
          "BroGL",
          WS_VISIBLE | WS_OVERLAPPEDWINDOW,
          0,
          0,
          width,
          height,
          NULL,
          NULL,
          hinstOpenGL,
          this
          );
  
      if (!hWnd) {
          // error creating the window
      }
  
      ShowWindow(hWnd, SW_SHOW);
      UpdateWindow(hWnd);
  }
  
  if (!(hDC = GetDC(hWnd))) {
      ShowWindow(hWnd, SW_HIDE);
      DestroyWindow(hWnd);
      hWnd = NULL;
      return false;
  }
  
  // Create OpenGL Context
  if (!MakeContext()) {
      ShowWindow(hWnd, SW_HIDE);
      DestroyWindow(hWnd);
      hWnd = NULL;
  
      return false;
  }
  
  SetForegroundWindow(hWnd);
  SetFocus(hWnd);
  
  return true;
  }
  </code></pre>
  
  <p>Let me know if any more information is required.</p>
  
  <p>EDIT: Here is the message loop.</p>
  
  <pre><code>LONG WINAPI BroGLWin::MainWndProc(HWND n_hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    switch (uMsg) {
      case WM_DESTROY:
        PostQuitMessage(0);
        break;
      case WM_CREATE:
      {
        LPCREATESTRUCT cs = reinterpret_cast&lt;LPCREATESTRUCT&gt;(lParam);
        void * lpCreateParam = cs-&gt;lpCreateParams;
        BroGLWin *win = reinterpret_cast&lt;BroGLWin *&gt;(lpCreateParam);
        assert(win == this);
      }
      return DefWindowProc(hWnd, uMsg, wParam, lParam);
    }
    return 0;
  }
  </code></pre>
  
  <p>EDIT 2: I have resolved my issue by properly implementing the message loop. The added code allowed the new messages to be read properly. Thanks to those who answered and left constructive comments. I also found the following website to be very helpful in this instance: <a href="http://www.winprog.org/tutorial/message_loop.html" rel="nofollow">http://www.winprog.org/tutorial/message_loop.html</a></p>
  
  <p>This is the code that I added to my <code>WinMain</code> function in <code>main.cpp</code></p>
  
  <pre><code>// pump the message loop
  while (PeekMessage(&amp;msg, NULL, 0, 0, PM_NOREMOVE)) {
      if (GetMessage(&amp;msg, NULL, 0, 0) &lt; 0) {
          // Some error checking
      }
      TranslateMessage(&amp;msg);
      DispatchMessage(&amp;msg);
  }
  </code></pre>