Hit test TTreview plus / minus (collapse / expand) icon - Delphi

I am using a TTreeview component in Delphi and I have configured the drag and drop functionality. I start dragging down with the mouse (as this is normal behavior), but I don't want to fire a drag event when the user clicks on the +/- icons or expands and collapses.

Is there a way to tell if the user has clicked on the header node or the expand / collapse icon?

Thank!

+3


source to share


1 answer


The component TTreeView

includes GetHitTestInfoAt

for this purpose.

procedure TForm1.TreeView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  HitTests: THitTests;
begin
  HitTests := TreeView1.GetHitTestInfoAt(X, Y);
  if htOnButton in HitTests then
    //do something
  else if htOnLabel in HitTests then
    //do something else
  else if ......

      



A complete list of possible set members THitTests

:

  • htAbove
  • htBelow
  • HTNOWHERE
  • htOnItem
  • htOnButton
  • htOnIcon
  • htOnIndent
  • htOnLabel
  • htOnRight
  • htOnStateIcon
  • htToLeft
  • htToRight
+5


source







All Articles