gertpienaar
asked on
system mouse events
How do I capture system mouse events in Delphi4.
I only want to execute a process after a right mouse click anywhere on the screen.
I only want to execute a process after a right mouse click anywhere on the screen.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot
Gert Pienaar
Gert Pienaar
ASKER
Barry.
I received an compiler error on the following line of code:
ourHook:=SetWindowsHookEx( WH_MOUSE,H ookProc,HI nstance,0) ;
I changed this to:
ourHook:=SetWindowsHookEx( WH_MOUSE,@ HookProc,H Instance,0 );
and it compiled OK.
I added the following code to an application:
function SetHook:Boolean; stdcall; external Hookdemo.dll';
function UnHookHook:Boolean; stdcall; external 'Hookdemo.dll';
function HookProc(Code:integer; wParam: Word; lParam: Longint):Longint; stdcall; external 'Hookdemo.dll';
and
procedure TForm1.Button2Click(Sender : TObject);
begin
SetHook;
end;
procedure TForm1.Button3Click(Sender : TObject);
begin
UnhookHook;
end;
Nothing happened when running the program and clicking the mouse
I then loaded this application as a Host Application into the Hookdemo project to try and debug. When clicking on button2 the code in the Sethook function is executed, but when clicking the left mouse, the code in the HookProc is not execvuted and nothing happens.
Clicking Button3 executes the UnhookHook code.
Any suggestions why it doesn't execute the code in the HookProc.
I received an compiler error on the following line of code:
ourHook:=SetWindowsHookEx(
I changed this to:
ourHook:=SetWindowsHookEx(
and it compiled OK.
I added the following code to an application:
function SetHook:Boolean; stdcall; external Hookdemo.dll';
function UnHookHook:Boolean; stdcall; external 'Hookdemo.dll';
function HookProc(Code:integer; wParam: Word; lParam: Longint):Longint; stdcall; external 'Hookdemo.dll';
and
procedure TForm1.Button2Click(Sender
begin
SetHook;
end;
procedure TForm1.Button3Click(Sender
begin
UnhookHook;
end;
Nothing happened when running the program and clicking the mouse
I then loaded this application as a Host Application into the Hookdemo project to try and debug. When clicking on button2 the code in the Sethook function is executed, but when clicking the left mouse, the code in the HookProc is not execvuted and nothing happens.
Clicking Button3 executes the UnhookHook code.
Any suggestions why it doesn't execute the code in the HookProc.
cheers madshi ;-)