Windows消息Capture

MSDN关于WM_MOUSEMOVE的说明:
The WM_MOUSEMOVE message is posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse. 
也就是说,你在比如ControlY单击鼠标后,系统就SetCapture,鼠标就被当前的Window Capture了(即ControlY),当你放开鼠标时才Release鼠标,因此此时当你把鼠标move到ControlX时,实际上是有WM_MOUSEMOVE事件发生的,只不过是Windows把此消息发给ControlY了,由ControlY的窗口过程处理的此消息。
由此可知,解决此问题有两种办法:
1:在ControlY单击鼠标后,设法不让Windows Capture鼠标;
2:在ControlY的WM_MOUSEMOVE事件中判断鼠标当前位置是不是在ControlX上,如果是,说明是在ControlX上MOUSEMOVE。

SetCapture

ReleaseCapture;//释放Mouse

posted @ 2013-04-11 13:33  ftwsnow  阅读(236)  评论(0编辑  收藏  举报