By default, the control gets a WM_LBUTTONUP message when the mouse moves outside of the control.
The following is obtained through the SetCapture function.
setcapture function Function:
This function sets mouse capture in the specified window that belongs to the current thread. Once the window captures the mouse, all mouse input is directed at the window, regardless of whether the cursor is within the bounds of the window. Only one window can capture the mouse at a time. If the mouse cursor is on a window created by another thread, the system will only point the mouse input to the specified window when the mouse button is pressed.
LRESULT CALLBACK TestProc (HWND hwnd, UINT MSG, WPARAM WPARAM, LPARAM LPARAM)
{
switch (msg)
{
case WM_LBUTTONDOWN://left button pressed
{
SetCapture (HWND);
}
Break ;
case WM_MOUSEMOVE://Mouse down move
{
if (getcapture () = = hwnd)
{
//Mouse Press and move ...
}
}
Break ;
Case Wm_lbuttonup://left button bounces
{
if (getcapture () = = hwnd)
releasecapture ();//When a window in the front thread releases the mouse capture and restores the usual mouse input processing.
}
Break ;
return 0;
}
}
How to capture this mouse bounce event when the mouse is pressed on a control and then bounces off