unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
protected
procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
procedure WMMButtonDown(var Message: TWMMButtonDown); message WM_MBUTTONDOWN;
procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN;
procedure MyMouseDown(Button: TMouseButton; X, Y: Integer);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.MyMouseDown(Button: TMouseButton; X,Y: Integer);
var
btn: string;
begin
case Button of
mbLeft: btn := '左鍵';
mbRight: btn := '右鍵';
mbMiddle: btn := '中鍵';
end;
ShowMessageFmt('%s: %d,%d', [btn,X,Y]);
end;
procedure TForm1.WMLButtonDown(var Message: TWMLButtonDown);
begin
MyMouseDown(mbLeft, Message.XPos, Message.YPos);
end;
procedure TForm1.WMMButtonDown(var Message: TWMMButtonDown);
begin
MyMouseDown(mbMiddle, Message.XPos, Message.YPos);
end;
procedure TForm1.WMRButtonDown(var Message: TWMRButtonDown);
begin
MyMouseDown(mbRight, Message.XPos, Message.YPos);
end;
end.