I'm creating a custom control which recognizes when the mouse is dragging, specifically using messages WM_LBUTTONDOWN
, WM_LBUTTONUP
, and WM_MOUSEMOVE
. When the mouse goes down, I capture the position on the control, and then when the mouse moves, if the left mouse button is down, I do more handling (calculating between starting and ending points).
The problem is, I'm expecting the mouse to go out of the control, and even out of the form, but when the mouse leaves the control, it no longer captures mouse events. Is there a way I can handle specifically the WM_MOUSEMOVE
and WM_LBUTTONUP
messages without the mouse being over the control?
You can use SetCapture/ReleaseCapture
Windows API to continue to get mouse events when the cursor moves outside the control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With