This example uses the WinSetCapture call to capture the mouse until the button is released. The user has selected a specific object with mouse button 2.
#define INCL_WININPUT #include <OS2.H> HWND hwnd; USHORT msg; WinSetCapture(hwnd,HWND_DESKTOP); switch (msg) { case WM_BUTTON2DOWN: /*******************************************************************/ /* An object has been picked. Set the mouse capture until */ /* a 'button up' message is detected. */ /*******************************************************************/ if (hwnd != WinQueryFocus(HWND_DESKTOP)){ WinSetFocus(HWND_DESKTOP, hwnd); } WinSetCapture(HWND_DESKTOP, hwnd); break; }