问题描述
你好,
我有一个带有聊天框控件的第三方应用程序,并且我希望每次更新聊天框时都将焦点放在父窗口上.
我检查了spy ++,发现每次添加新行时,控件都会收到P WM_PAINT.
我尝试自己挂接它(通过挂接WH_GETMESSAGE),并在每次收到WM_PAINT时写入日志,但是即使spy ++显示活动,日志也没有显示任何内容.
我认为这样做的原因是我检查了消息是否属于控件,并且在写入日志之前确实是WM_PAINT,而我执行此操作的方式是通过解析lParam的值:
Hello,
I have a 3rd party application with a chat box control, and I want to focus the parent window every time the chat box is updated.
I checked with spy++, and saw that the control receives P WM_PAINT every time a new line is added.
I tried hooking it myself (by hooking WH_GETMESSAGE) and writing to the log every time WM_PAINT is received, however the log showed nothing, even though spy++ showed activity.
I assume that the reason for that is that I checked if the message belongs to the control, and that it is indeed WM_PAINT before writing it the log, and the way I did it was by parsing the value of lParam:
CWPSTRUCT* cwps = (CWPSTRUCT*)lParam;
if ((cwps->hwnd != mWindowID) || (cwps->message != WM_PAINT))
return CallNextHookEx(key, nCode, wParam, lParam);
有道理,上述条件不会通过,例如,如果lParam为null,这恰好是spy ++对每条WM_PAINT消息接收显示的内容.
所以我的问题是:
spy ++如何知道特定控件在没有lParam的情况下收到WM_PAINT消息?
预先感谢,
Elad
It makes sense that the above condition will not pass, if for example lParam is null, which is EXACTLY what spy++ showed for every WM_PAINT message receives.
So my question is:
How does spy++ know that the specific control received a WM_PAINT message without the lParam?
Thanks in advance,
Elad
推荐答案
<00006> 000903E6 P WM_PAINT hdc:00000000 [wParam:00000000 lParam:00000000]
<00007> 000903E6 P WM_PAINT hdc:00000000 [wParam:00000000 lParam:00000000]
<00008> 000903E6 P WM_PAINT hdc:00000000 [wParam:00000000 lParam:00000000]
<00009> 000903E6 P WM_PAINT hdc:00000000 [wParam:00000000 lParam:00000000]
<00010> 000903E6 P WM_PAINT hdc:00000000 [wParam:00000000 lParam:00000000]
<00011> 000903E6 P WM_PAINT hdc:00000000 [wParam:00000000 lParam:00000000]
<00012> 000903E6 P WM_PAINT hdc:00000000 [wParam:00000000 lParam:00000000]
这篇关于spy ++和WM_PAINT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!