unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private-Deklarationen }
procedure WMNCHITTEST(
var Message: TWMMouseMove);
message WM_NCHITTEST;
procedure CMMouseLeave(
var Message: TMessage);
message CM_MOUSELEAVE;
procedure CMMouseEnter(
var Message: TMessage);
message CM_MOUSEENTER;
procedure WMMouseMove(
var Message: TWMMouseMove);
message WM_MOUSEMOVE;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
hMouseHook: HHOOK;
function MouseHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): Integer;
stdcall;
implementation
{$R *.dfm}
function MouseHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): Integer;
stdcall;
var
CTRLID : Word;
begin
case nCode < HC_ACTION
of
True: Result := CallNextHookEx(hMouseHook,nCode,wParam,lParam);
else
CTRLID := GetDlgCtrlID(PMOUSEHOOKSTRUCT(lParam)^.hwnd);
//if CTRLID <> 0 then
begin
SendMessage(Application.Handle,WM_MOUSEMOVE,wParam,lParam);
end;
Result := CallNextHookEx(hMouseHook,nCode,wParam,lParam);
end;
end;
procedure TForm1.CMMouseEnter(
var Message: TMessage);
begin
end;
procedure TForm1.CMMouseLeave(
var Message: TMessage);
begin
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Self.Top := 0;
hMouseHook := SetWindowsHookEx(WH_MOUSE,@MouseHookProc,0,GetCurrentThreadId());
end;
procedure TForm1.WMNCHITTEST(
var Message: TWMMouseMove);
begin
inherited;
Label1.Caption := IntToStr(
Message.XPos) + '
x ' + IntToStr(
Message.YPos);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnhookWindowsHookEx(hMouseHook);
end;
procedure TForm1.WMMouseMove(
var Message: TWMMouseMove);
begin
Label1.Caption := IntToStr(
Message.XPos) + '
x ' + IntToStr(
Message.YPos);
end;
end.