Autor Beitrag
breakdancer1111
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 148

Windows 7 Home Premium 64Bit
Delphi XE2 Starter
BeitragVerfasst: Mo 06.02.06 17:24 
Hallo erstmal!

Habe wieder einmal ein Problem. Ich schlage mich grade mit Hooks herum und
komme nicht weiter.

Es passiert einfach nichts.

hook.dll
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
function MouseProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
  if wParam = WM_LBUTTONDOWN then ShowMessage('beep');
  Result := CallNextHookEx(HookHandle, nCode, wParam, lParam);
end;

function InstallHook(Hwnd: Cardinal): Boolean; stdcall;
begin
  Result := False;
  if HookHandle = 0 then begin
    HookHandle := SetWindowsHookEx(WH_Mouse, @MouseProc, HInstance, 0);
    WindowHandle := Hwnd;
    Result := TRUE;
  end;
end;

function UninstallHook: Boolean; stdcall;
begin
  Result := UnhookWindowsHookEx(HookHandle);
  HookHandle := 0;
end;

exports
  InstallHook,
  UninstallHook;


Programm
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
  function InstallHook(Hwnd: Cardinal): Boolean; stdcall; external 'hook.dll';
  function UninstallHook: Boolean; stdcall; external 'hook.dll';

...

procedure TForm1.Button1Click(Sender: TObject);
begin
  if InstallHook(handle) then UninstallHook;
end;


So wenn ich nun auf button1 klicke und dannach woanders hin,
passiert einfach nichts.

Habe mir schon das Tutorial auf delphi-source.de durchgelesen
werde aber nicht so richtig schlau daraus.

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt