用消息实现窗体的 MouseDown 事件

用消息实现窗体的 MouseDown 事件

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    procedure WMMouseDown(var msg: TMessage); message WM_LBUTTONDOWN;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//运行后在窗体上点击左键会激活:
procedure TForm1.WMMouseDown(var msg: TMessage);
begin
  ShowMessage('WM_LBUTTONDOWN');
end;

//运行后在窗体上点击右键会激活:
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  ShowMessage('这是Delphi事件');  //被阻挡,但没有阻挡右键
end;

end.
posted on 2007-12-08 19:00  万一  阅读(3683)  评论(1)  编辑  收藏
上一篇:WPF 踩坑笔记6 无边框窗体拖拽


下一篇:WPF Button MouseDown事件