How to capture this mouse bounce event when the mouse is pressed on a control and then bounces off

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.