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.

posted on 2008-10-30 11:39  万一  阅读(2244)  评论(3编辑  收藏  举报