procedure TForm1.TreeView1Click(Sender: TObject);
var
  aPoint: TPoint;
  aNode: TTreeNode;
  aHitTest: THitTests;
begin
  if GetCursorPos(aPoint) then
  begin
    aPoint := TreeView1.ScreenToClient(aPoint);
    aHitTest := TreeView1.GetHitTestInfoAt(aPoint.X, aPoint.Y);

    //htOnItem, htOnButton, htOnIcon, htOnIndent, htOnLabel
    if not ((htOnItem in aHitTest)or (htOnLabel in aHitTest)) then  Exit;

    aNode := TreeView1.GetNodeAt(aPoint.X, aPoint.Y);
    if not Assigned(aNode) then  Exit;

    //test: Caption := aNode.Text;
    //do your code
  end;
end;

procedure TForm1.TreeView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  aNode: TTreeNode;
begin
  aNode := TreeView1.GetNodeAt(X, Y);
  if not Assigned(aNode) then  Exit;

  //do your code
end;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
猜你喜欢
  • 2021-12-05
  • 2021-07-24
  • 2021-08-29
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案