首页
社区
课程
招聘
高手来看看。WH_GETMESSAGE和窗口消息的问题。
发表于: 2006-7-11 17:41 17023

高手来看看。WH_GETMESSAGE和窗口消息的问题。

2006-7-11 17:41
17023
问题是这样的:

我的程序想向windows中其他程序的窗口发送消息, 消息是用WM_USER + X 定义的。

现在我想自己拦截这个消息并处理它, 我用的是WH_GETMESSAGE挂钩。

但为什么有时候会拦截不到呢?
请朋友们给我指点下。

还有。 我用spy++看到。 当我的鼠标移进或移出一个窗口时, 这个窗口会收到一个0x02A2 消息, 这个消息是什么啊?  

小弟期待朋友们帮助。 谢谢啊。。

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (6)
雪    币: 196
活跃值: (135)
能力值: ( LV10,RANK:170 )
在线值:
发帖
回帖
粉丝
2
0x2A2 == WM_NCMOUSELEAVE

WM_NCMOUSELEAVE Notification

The WM_NCMOUSELEAVE message is posted to a window when the cursor leaves the nonclient area of the window specified in a prior call to TrackMouseEvent.

A window receives this message through its WindowProc function.

WM_NCMOUSELEAVE

    WPARAM wParam
    LPARAM lParam;
   

Parameters

wParam
Not used, must be zero.
lParam
Not used, must be zero.
Return Value

If an application processes this message, it should return zero.

Remarks

All tracking requested by TrackMouseEvent is canceled when this message is generated. The application must call TrackMouseEvent when the mouse reenters its window if it requires further tracking of mouse hover behavior.
2006-7-11 18:22
0
雪    币: 208
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
谢谢朋友的指点。 第一个问题有朋友能讲下吗? 谢谢。
我用SendMessage发送消息的话, 钩子函数里面收不到。
但是我用PostMessage发送的话钩子函数里面就可以收到。
这是为什么?
2006-7-12 12:00
0
雪    币: 2384
活跃值: (766)
能力值: (RANK:410 )
在线值:
发帖
回帖
粉丝
4
MSDN里说的很明显了。WH_GETMESSAGE Hook只拦截由GetMessage or PostMessage的消息,不能拦截由SendMessage引起的消息。

he WH_GETMESSAGE hook enables an application to monitor messages about to be returned by the GetMessage or PeekMessage function. You can use the WH_GETMESSAGE hook to monitor mouse and keyboard input and other messages posted to the message queue.
2006-7-12 17:18
0
雪    币: 2384
活跃值: (766)
能力值: (RANK:410 )
在线值:
发帖
回帖
粉丝
5
要Hook SendMessage必须Hook WH_CALLWNDPROC and WH_CALLWNDPROCRET Hooks

The WH_CALLWNDPROC and WH_CALLWNDPROCRET hooks enable you to monitor messages sent to window procedures by the SendMessage function. Windows calls a WH_CALLWNDPROC hook procedure before passing the message to the receiving window procedure, and calls the WH_CALLWNDPROCRET hook procedure after the window procedure has processed the message.

The WH_CALLWNDPROCRET hook passes the address of a CWPRETSTRUCT structure to the hook procedure. The structure contains the return value from the window procedure that processed the message, as well as the message parameters associated with the message. Subclassing the window does not work for messages set between processes.
2006-7-12 17:20
0
雪    币: 208
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
哦。 知道了。 原来是这样。 我以前都没注意这个。
谢谢版主啊。 以后多向大家学习。
2006-7-12 17:45
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
怎么进不了论坛了,只能进这里,想提个问题,如何hook一个进程的建立,用了很多方法都不行,请高手指教下
2006-11-25 08:50
0
游客
登录 | 注册 方可回帖
返回
//