title: The curious problem of the missing WM_NCLBUTTONUP message when a window isn't maximised
body: <p>I've got a window that I handle WM_NCLBUTTONUP messages, in order to handle clicks on custom buttons in the caption bar. This works great when the window is maximised, but when it's not, the WM_NCLBUTTONUP message never arrives! I do get a WM_NCLBUTTONDOWN message though. Strangely WM_NCLBUTTONUP does arrive if I click on the right of the menu bar, but anywhere along the caption bar / window frame, the message never arrives.</p>
  
  <p>After a while of debugging I discovered that if I set a breakpoint on CMainFrame::OnNcLButtonDown(), clicked the caption bar, but keep the mouse button held down, let the debugger break in the function, hit F5 to continue debugging, then release the mouse button - magically WM_NCLBUTTONUP is sent!!</p>
  
  <p>My question is two-fold, (1) what the hell is going on? (2) how do I get around this "problem".</p>
  
  <p>I also note that there are several other people on the internet who have the same issue (a quick Google reveals lots of other people with the same issue, but no solution).</p>
  
  <p><strong>Edit</strong><br>
  Thanks for the first two replies, I've tried calling ReleaseCapture in NCLButtonDown, but it has no effect (in fact, it returns NULL, indicating a capture is not in place). I can only assume that the base class (def window proc) functionality may set a capture. I shall investigate on Monday...</p>