Unit1.pas
上传用户:kukotwo
上传日期:2007-01-29
资源大小:188k
文件大小:2k
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- MapFileUnit;
- type
- TForm1 = class(TForm)
- procedure FormCreate(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- private
- { Private declarations }
- public
- { Public declarations }
- procedure WndProc(var Mess: TMessage); override;
- end;
- var
- Form1: TForm1;
- ZW_MSG : UINT;
- HMapFile:THandle;
- CommonData:pCommonData;
- implementation
- {$R *.DFM}
- function EnableMouseHook(hld:hwnd): boolean; stdcall; external 'MHK.dll';
- function DisableMouseHook: boolean; stdcall; external 'MHK.dll';
- procedure TForm1.WndProc(var Mess: TMessage);
- begin
- if (mess.msg = ZW_MSG) then
- begin
- caption := 's';
- if CommonData<>nil then with CommonData^ do
- Caption := Format('Mouse Pos: %d, Y : %d',
- [MousePos.X,
- MousePos.Y]);
- end;
- inherited;
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- ZW_MSG := RegisterWindowMessage('WM_ZWNOTIFY');
- //CommonData := nil;
- MapCommonData(CommonData,HMapFile);
- if not(EnableMouseHook(handle)) then ShowMessage('Enable Mouse Hook failed.');
- end;
- procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- if not(DisableMouseHook) then ShowMessage('Disable Mouse Hook failed.');
- if CommonData<>nil then UnMapCommonData(CommonData,HMapFile);
- end;
- end.
-