您好,是否有任何包含这 2 个鼠标事件的 VirtualStringTree 版本:
OnMouseEnter
和OnMouseLeave
?
您好,是否有任何包含这 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;