首页 > 代码库 > delphi treeview 鼠标移动显示hint信息

delphi treeview 鼠标移动显示hint信息

procedure TForm1.TreeView1MouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
var
  Node: TTreeNode;
begin
  with TreeView1 do
  begin
    Node := GetNodeAt(X, Y);
    ShowHint := (Node <> nil);
    if ShowHint then
    begin
      Hint := Node.Text;
      Application.ActivateHint(Mouse.CursorPos);
    end;
  end;
end;



//OR

procedure TForm1.TreeView1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
{$J+}
const
  OldItem: TTreeNode = nil;
{$J-}
var
  AnItem: TTreeNode;
begin
  AnItem := TTreeView(Sender).GetNodeAt(X, Y);
  if Assigned(AnItem) and (AnItem <> OldItem) then begin
    TTreeView(Sender).Hint := AnItem.Text;
    Application.ActivateHint(Mouse.CursorPos);
    OldItem := AnItem;
  end;
end;

来源: <delphi treeview 鼠标移动显示hint信息_妙馨_新浪博客>
 

来自为知笔记(Wiz)