title: How do I stop Windows from blocking the program during a window drag or menu button being held down?
body: <p>I am novice with <a href="http://en.wikipedia.org/wiki/Windows_API" rel="noreferrer">Win32</a>, and I have been pursuing a problem (if it can be called a problem at all) with Windows blocking your program's flow during the event when a user grabs the window title bar and moves it around the screen.</p>
  
  <p>I have no legitimate reason to solve this problem, except that it bothers me. A few possibilities include removing the frame altogether, but it seems an inconvenient hack. Some games (single player) do not find this a problem at all. I have read however, that multiplayer games might experience problems when the program freezes as it expects continuous flow of information and can be overwhelmed after such a delay.</p>
  
  <p>I have tried adding this to my <code>WindowProc</code></p>
  
  <pre><code>switch (uMsg)
  {
      case WM_SYSCOMMAND:
          if (wParam == SC_CLOSE)
              PostQuitMessage(0);
  
          return 0;
      ...
      ...
      default:
          return DefWindowProc(hwnd, uMsg, wParam, lParam);
  }
  return 0;
  </code></pre>
  
  <p>And this seems a quick hack, except that when I mousedown over the close icon I can pull the mouse away and let go without closing the program, and during that time, when the close icon is held down, the program once again is blocked.</p>
  
  <p>Furthermore, I do not know how to manually include the code necessary to move the window when the user clicks the titlebar and drags the mouse. For starters I do not know which <code>uMsg</code>'s and <code>wParam</code>'s to handle.</p>
  
  <p>My question is then, how do I disallow blocking during the case when the user clicks down the exit button (or minimize/maximize buttons) while still handling the case when the mouse is clicked and released over the button, and how do I allow the user to move/drag the window without it blocking the program (or what message is sent when the title bar is clicked without it being a button or menu)?</p>
  
  <p>I am creating the window with <code>WS_SYSMENU | WS_MINIMIZEBOX</code>.</p>
  
  <p>I still want the program to respond to minimize, maximize, and exit commands.</p>
  
  <p>If multi-threading can fix it, then that is interesting, but I wonder if I can get it to work on single-core processors. And I have read about hooks, but the MSDN page is still hard for me to interpret.</p>