鼠标静止不动时候的消息

优化程序的时候发现鼠标放在控件上不动也会不停的收到WM_MOUSEMOVE消息。

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 = <no type information>

764812a5 USER32!PostMessageW = <no type information>

764904e3 USER32!PackAndPostMessage = <no type information>

76481285 USER32!NtUserPostMessage = <no type information>

 

0:035> x USER32!*SendMessage*

7648781f USER32!SendMessageTimeoutA = <no type information>

764e0030 USER32!_imp__WinStationSendMessageW = <no type information>

764797d2 USER32!SendMessageTimeoutW = <no type information>

7647d611 USER32!SendMessageToUI = <no type information>

764838ee USER32!InSendMessageEx = <no type information>

764da9a8 USER32!WinStationSendMessageW = <no type information>

764d886b USER32!NtUserQuerySendMessage = <no type information>

764797fc USER32!SendMessageTimeoutWorker = <no type information>

*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 spurious WM_MOUSEMOVE message.    

转载于:https://www.cnblogs.com/liuhan333/p/4705727.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值