给到一百分,谁能拿?
主 题:MouseHook的一小问题?
作 者:soft_air
所属论坛:Visual C++
问题点数:20
回复次数:0
人气指数:7
发表时间:2001-2-28 18:43:00
按他人原码做了个MouseHook,定义为全局钩子,但不能钩到所有applications,只钩到了使用钩子的application(mouse)的mouse消息。EDIT控件里只出现了mouse的窗口标题mouse,别的没出现,why?SetWindowsHookEx (..,..,..,0)
HWND glhTargetWnd=pMouseHook->hwnd;
//取目标窗口句柄
HWND ParentWnd=glhTargetWnd;
while (ParentWnd !=NULL)
{
glhTargetWnd=ParentWnd;
ParentWnd=GetParent(glhTargetWnd);
//取应用程序主窗口句柄
}
if(glhTargetWnd!=glhPrevTarWnd)
{
char szCaption[100];
GetWindowText(glhTargetWnd,szCaption,100);
//取目标窗口标题
if(IsWindow(glhDisplayWnd))
SendMessage(glhDisplayWnd,WM_SETTEXT,0,(LPARAM)(LPCTSTR)szCaption);
glhPrevTarWnd=glhTargetWnd;
//保存目标窗口
}