W
wonsfon
Unregistered / Unconfirmed
GUEST, unregistred user!
动态库总会写吧<br>在动态库中写一个类似于<br>var<br> hHook: THandle;//全局变量,保存钩子句柄<br> wnd: THandle;//调用窗口的句柄<br>procedure GetMsgProc(Code: Integer;wPara: WPARAM;lPara: LPARAM);//钩子的回调函数<br>var<br> msg: TMSG;<br>begin<br> @msg:= lPara;<br> if msg.Message = WM_KillFocus then<br> PosMessage(wnd,WM_User+8008,msg.wParam,msg.lParam);<br>end;<br><br>procedure InstallHook(hwnd: THandle;Flag:Boolean);//hwnd 为调用窗口的句柄,flag: true 为安装钩子,false为卸掉钩子<br>begin<br> if Flag then<br> begin <br> hHook:= SetWindowsHookEx(WH_GETMESSAGE,@GetMsgProc,hInstance,0);//安装消息钩子<br> wnd:= hwnd;<br> end<br> else UnhookWindowsHookEx(hHook);//卸掉安装的钩子<br>end;<br><br>然后在你的调用窗口调用它<br>formcreate时InstallHook(Handle,true)<br>收到WM_User+8008时就可以得到你想要的那个句柄<br>剩下的不用我说了吧