当前位置 : 主页 > 编程语言 > delphi >

Delphi VirtualStringTree OnMouseEnter和OnMouseLeave

来源:互联网 收集:自由互联 发布时间:2021-06-23
您好,有没有包含这2个鼠标事件的VirtualStringTree版本: OnMouseEnter和OnMouseLeave? 如果您的字符串树不支持它们,这些事件很容易添加. TMyImprovedVirtualStringTree = class(TSomeVirtualStringTree) private
您好,有没有包含这2个鼠标事件的VirtualStringTree版本:

OnMouseEnter和OnMouseLeave?

如果您的字符串树不支持它们,这些事件很容易添加.

TMyImprovedVirtualStringTree = class(TSomeVirtualStringTree)
  private
    FOnMouseEnter: TNotifyEvent;
    FOnMouseLeave: TNotifyEvent;

    // Watch for MouseEnter and MouseLeave messages...
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
  protected
    // Provide MouseEnter() and MouseLeave() methods
    // for descendent controls to override if needed.
    procedure MouseEnter; virtual;
    procedure MouseLeave; virtual;
  published
    // Publish the events so they show in Delphi's object inspecter.
    property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
  end;

implementation

{ TMyImprovedVirtualStringTree }

procedure TMyImprovedVirtualStringTree.CMMouseEnter(var Message: TMessage);
begin
  inherited;
  MouseEnter;
end;

procedure TMyImprovedVirtualStringTree.CMMouseLeave(var Message: TMessage);
begin
  inherited;
  MouseLeave;
end;

procedure TMyImprovedVirtualStringTree.MouseEnter;
begin
  if Assigned(FOnMouseEnter) then
    FOnMouseEnter(Self);
end;

procedure TMyImprovedVirtualStringTree.MouseLeave;
begin
  if Assigned(FOnMouseLeave) then
    FOnMouseLeave(Self);
end;
网友评论