优化程序的时候发现鼠标放在控件上不动也会不停的收到WM_MOUSEMOVE消息。
创新互联提供成都网站设计、成都网站建设、网页设计,高端网站设计,1元广告等致力于企业网站建设与公司网站制作,10余年的网站开发和建站经验,助力企业信息化建设,成功案例突破近千家,是您实现网站建设的好选择.1,
于是想了各种办法寻找是哪儿触发的。
bp USER32!PostMessageW ".echo PostMessageW_Breakpoint_hit; g"
bp USER32!SendMessageW ".echo SendMessageW_Breakpoint_hit; g"
*Message没有抓到WM_MOUSEMOVE消息,却触发了该消息。
0:035> x USER32!*PostMessage*
76483baa USER32!PostMessageA =
764812a5 USER32!PostMessageW =
764904e3 USER32!PackAndPostMessage =
76481285 USER32!NtUserPostMessage =
0:035> x USER32!*SendMessage*
7648781f USER32!SendMessageTimeoutA =
764e0030 USER32!_imp__WinStationSendMessageW =
764797d2 USER32!SendMessageTimeoutW =
7647d611 USER32!SendMessageToUI =
764838ee USER32!InSendMessageEx =
764da9a8 USER32!WinStationSendMessageW =
764d886b USER32!NtUserQuerySendMessage =
764797fc USER32!SendMessageTimeoutWorker =
*Message* 全部bp一遍也没有抓到。
2,
用vs2005创建一个WIN32程序,只在WndProc里面加上WM_MOUSEMOVE的打印:
鼠标不动依然受到了WM_MOUSEMOVE消息,
3,
原来鼠标在窗口上不动也会收到这几个消息:
#define WM_GETICON 0x007F
#define WM_NCHITTEST 0x0084
#define WM_SETCURSOR 0x0020
#define WM_MOUSEMOVE 0x0200
-------------------------------------------------------------!
用spy++抓了一下,有的窗口能抓到有的不能抓到。
4,
看看MSDN怎么说
his message is posted to a window when user moves the mouse while pressing the left mouse button or moves the stylus while the tip is down. If another window does not capture the mouse stylus input, the OS posts the message to the window that contains the cursor or the stylus tip. If another window captures the mouse or stylus input, the OS posts the message to the window that has the capture.
Okay, so back to the original question, "Why do I get spurious WM_MOUSEMOVE messages?"
Notice that the delivery of a mouse message includes lots of work that is typically thought of as being part of mouse movement. Often, Windows wants to do that follow-on work even though the mouse hasn't actually moved. The most obvious example is when a window is shown, hidden or moved. When that happens, the mouse cursor may be over a window different from the window it was over previously (or in the case of a move, it may be over a different part of the same window). Windows needs to recalculate the mouse cursor (for example, the old window may have wanted an arrow but the new window wants a pointy finger), so it artificially sets the "The mouse moved, in case anybody cares" flag. This causes all the follow-on work to happen, a side-effect of which is the generation of a spuriousWM_MOUSEMOVE message.
当前文章:鼠标静止不动时候的消息-创新互联
URL地址:http://scyingshan.cn/article/iddoi.html