0

When I click on a non-reactive area of a win32 window in the foreground (for example, a blank space on a menu bar) and drag the mouse off, background windows do not receive mouse events. Buttons don't got into hover state, the cursor doesn't change, etc. The mouse is "captured" by the foreground window, although it doesn't receive messages either unless the mouse is over it. This state persists until I release the mouse button. Why is this, and how can I get out of this state programmatically without releasing the mouse button?

Researching this issue, I thought at first it was related to the concept of mouse capture, but it appears it is not. GetCapture() returns NULL during this state, whatever it is.

Clarification Edit: This is easy to see in the simplest of applications. Create a new Win32 project in Visual Studio with the default project template, which makes an empty window. Run it, and click and hold the blank inside of the window. Drag the mouse outside the window, and note that no buttons in background windows light up or otherwise respond to mouse-over events. Even if I stick ReleaseCapture() in the WndProc so that it fires after every message, the result is the same. It really seems like this has nothing to do with mouse capture in the Get/SetCapture sense.

Paul Accisano
  • 1,416
  • 1
  • 14
  • 25
  • This is related to mouse capture, you just didn't read the documentation for [GetCapture](https://msdn.microsoft.com/en-us/library/windows/desktop/ms646257.aspx): *"A NULL return value means the current thread has not captured the mouse. However, it is possible that another thread or process has captured the mouse."* If you're wondering, why it is implemented the way it is, have a look at Qt, where this feature is not present. In a Qt application it is possible to inadvertently move a splitter bar while the intention is to drag an object across it. Amongst lots of other breakage. – IInspectable Apr 12 '16 at 08:50
  • I did read that. When I said GetCapture returns null, I meant it returns null from the UI thread of the app I'm dragging the mouse out of. What other thread or process could it be? – Paul Accisano Apr 12 '16 at 13:23

0 Answers0