Thank you for your attention.
How can I make to work drag and drop using TAdvTreeViewNode, not TAdvTreeViewVirtualNode?
I need to find a method similar to XYToNode(X, Y), this method only works for TAdvTreeViewVirtualNode.
I have the following code that works with a different TreeView control:
procedure TTree_AJ.TreeViewDragDrop(Sender, Source: TObject; X, Y: Integer);
var
TargetNode, SourceNode: TFlyNode;
begin
TargetNode := AJ_Tree.GetNodeAt(X, Y);
if ( TargetNode <> nil ) then begin
SourceNode := AJ_Tree.Selected;
SourceNode.MoveTo(TargetNode, naInsert);
// naAdd Adds the node to the end of the list.
// naAddFirst Adds the node at the beginning of the list.
// naAddChild Adds the node as a child of the destination at the end of the child list.
// naAddChildFirst Adds the node as a child at the beginning of the child list of the destination.
// naInsert Insert the node before the destination node.
end;
end;
procedure TTree_AJ.TreeViewDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
var
TargetNode, SourceNode: TFlyNode;
begin
TargetNode := AJ_Tree.GetNodeAt(X, Y);
// Accept dragging from itself
if ( Source = Sender ) and ( TargetNode <> nil ) then begin
Accept := True;
// Determines source and target
SourceNode := AJ_Tree.Selected;
// Look up the target parent chain
while ( TargetNode.Parent <> nil ) and
( TargetNode <> SourceNode ) do
TargetNode := TargetNode.Parent;
// If source is found
if ( TargetNode = SourceNode ) then
// Do not allow dragging over a child
Accept := False;
end // if ...
else
Accept := False;
end;