Hit Test TTreview plus/minus (collapse/expand) icon
I am using a TTreeview component in Delphi and I have customized the drag and drop functions. I start the drag on the mouse down (since it is a custom behavior), but I don't want to start the drag event when the user click on the +/- or expand and collapse icons.
Is there a way to know if the user has clicked on the caption of the node or on the expand/collapse icon?
Thanks!
The TTreeView
component includes the GetHitTestInfoAt
method 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 ......
The full list of possible members of the THitTests
set is: