/*
GetNodeAt, MoveTo, Selected example
The following code uses GetNodeAt to add a dragged node as a child of the node under then mouse when it is dropped.
*/ 
void __fastcall TForm1::TreeView1DragDrop(TObjectTObject *Sender, TObjectTObject *Source, int X, int Y)
{
  if (Source != (TObjectTObject *)TreeView1 || TreeView1->Selected == NULL)
    return;
  THitTests HT = TreeView1->GetHitTestInfoAt(X, Y);
  TNodeAttachMode AttachMode;
  TTreeNode!AL(`ttreenode_object',1,`TopicNotFound',`main') *pItem = TreeView1->GetNodeAt(X, Y);
  if (HT.Contains(htOnItem) || HT.Contains(htOnIcon))
    AttachMode = naAddChild;
  else if (HT.Contains(htNowhere))
    AttachMode = naAdd;
  else if (HT.Contains(htOnIndent))
    AttachMode = naInsert;
  else
    return;
  TreeView1->Selected->MoveTo(pItem, AttachMode);
}
 
