主题:求助HOOK问题
function zgc1(iCode: Integer; wparam:wparam; lparam: lparam): lresult; stdcall;
var
dwLen:DWORD;
himc:HWND;
hFocus:THandle;
pcs : pmsg;
cchar1 : pchar ;
begin
Result:= CallNextHookEx(stratgzjb, iCode, wParam, lParam);
if (iCode = HC_ACTION) then
begin
pcs:=pmsg(lparam);
if PCs^.message = WM_IME_COMPOSITION then
begin
hFocus := GetFocus();
HIMC := ImmGetContext(hFocus);
if HIMC = 0 then Exit;
dwLen := ImmGetCompositionString(hImc,GCS_RESULTSTR,nil,0);
if dwLen > 0 then
begin
if ImmGetCompositionString(HIMC, GCS_RESULTSTR, cchar1, dwLen + sizeof(WCHAR)) > 0 then
begin
ImmGetCompositionString(HIMC, GCS_RESULTSTR, cchar1, dwLen + sizeof(WCHAR));
end;
ImmReleaseContext(hFocus, HIMC1);
end;
pcs:=nil;
end;
end;
end;
procedure stratgz1; stdcall;
begin
stratgzjb := setwindowshookex(WH_GETMESSAGE, zgc1, hinstance, 0);
end;
这段代码不能捕获到键盘操作包括WM_KEYDOWN等,但如果WM_IME_COMPOSITION 换成WM_LBUTTONUP却能捕获到鼠标,请问这是为什么?
请大家帮帮我,我是在DELPHI7和WINXPSP2中测试的