看书,没怎么看懂,想请各位高手详细解释一下,,以下这段代码:
type TNQRDBText = class(TQRDBText)
  private
    { Private declarations }
    FOnMouseUp: TMouseEvent;
    FOnMouseDown: TMouseEvent;
    procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
    procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
    procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN;
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
    property OnMouseMove;
    property OnClick;
    property OnMouseDown: TMouseEvent Read FonMouseDown Write FonMOuseDown;
    property OnMouseUp: TMouseEvent Read FonMouseUp Write FonMouseUp;
  end;procedure Register;implementation
uses
    Consts, Forms, ActiveX;procedure TNQRDBText.WMLButtonDown(var Message: TWMLButtonDown);
begin
  inherited;
  with Message do
    if Assigned(FOnMouseDown) then FOnMouseDown(Self, mbLeft, KeysToShiftState(Keys), XPos, YPos);
end;procedure TNQRDBText.WMLButtonUp(var Message: TWMLButtonUp);
begin
  inherited;
  with Message do
    if Assigned(FOnMouseUp) then FOnMouseUp(Self, mbLeft, KeysToShiftState(Keys), XPos, YPos);
end;procedure TNQRDBText.WMRButtonDown(var Message: TWMRButtonDown);
begin
  inherited;
  with Message do
    if Assigned(FOnMouseDown) then FOnMouseDown(Self, mbRight, KeysToShiftState(Keys), XPos, YPos);
end;

解决方案 »

  1.   

    1。property OnMouseDown: TMouseEvent是个属性而已,只不过是一个特殊的属性,也就是过程属性。
    比如我们双击一个form,对进入FormCreate事件,其实这只是在定义一个静态属性,也就是一个过程代码了,他是静态的放在那的,是不会主动的运行的。
    2。procedure WMRButtonDown(var Message: TWMRButtonDown); message,也是一个过程,不过这个过程会被某个鼠标消息触发,其实也就是在出发了这个过程后,会在这个过程里去主动调用你在1中定义的静态代码。其实,VCL中类似的代码很多。
      

  2.   

    你可以把事件理解为特殊的属性,事件属性保存的是函数指针而已。当执行特定操作时,就触发事件,执行事件代码。当然,事件属性要有值。所以控件中调用事件都是这样写的:
    if Assigned(FOnClickEvent) then
      FOnClickEvent(self);事件不一定是消息触发,比如某个赋值操作可以触发一个事件,等待用户执行一些操作。
      

  3.   

    上面是不是还有 TMouseEvent=procedure(.....................);
      

  4.   

    顶啊,顶,我顶……顶。我也刚刚学会做VCL控件,也根大家学习。