HWND SetCapture( HWND hWnd // handle to window ); Parameters hWnd [in] Handle to the window in the current thread that is to capture the mouse. Return Values The return value is a handle to the window that had previously captured the mouse. If there is no such window, the return value is NULL. 用完以后BOOL ReleaseCapture(VOID);
HWND hWnd // handle to window
);
Parameters
hWnd
[in] Handle to the window in the current thread that is to capture the mouse.
Return Values
The return value is a handle to the window that had previously captured the mouse. If there is no such window, the return value is NULL. 用完以后BOOL ReleaseCapture(VOID);
CRect rc;
GetWindowRect(&rc);
ClipCursor(&rc);
CPoint pt;//赋你要移动的鼠标位置
SetCursorPos(pt); //你会看到鼠标移动范围被限制在本窗口内
ClipCursor(NULL); //接除对鼠标移动范围的限制
SetCursorPos(380,175);
想把mouse_event产生的消息直接发给这个界面,就用了postmessage函数,但是鼠标没法移动,其中一句有效 ::PostMessage(hwnd,WM_LBUTTONDOWN,01,0); (该界面不处于活动时候也有鼠标点击的消息,不会把我当前的工作窗口无效掉)
所以用setcapture
想把mouse_event产生的消息直接发给这个界面,就用了postmessage函数,但是鼠标没法移动,其中一句有效 ::PostMessage(hwnd,WM_LBUTTONDOWN,01,0); (该界面不处于活动时候也有鼠标点击的消息,不会把我当前的工作窗口无效掉)所以不想用SetCapture,那样我当前的工作窗口也用不了鼠标了。