这是我程序的一部分你看看吧:
这是粘贴事件
procedure TTreeFrame.PasteItemClick(Sender: TObject);
var
DNode: TTreeNode; //目标节点
AttachMode: TNodeAttachMode; //移动方式
HT: THitTests; //目标鼠标在树上的位置
begin
if FCutNode<>nil then
begin
HT := TreeView.GetHitTestInfoAt(FPoint.X, FPoint.Y);//Ffpoint是当前鼠标位置
DNode := TreeView.GetNodeAt(FPoint.X, FPoint.Y);
FPastNode:=DNode;
if (HT - [htOnItem, htOnIcon, htNowhere, htOnIndent] <> HT) then
begin
if (htOnItem in HT) or (htOnIcon in HT) then AttachMode := naAddChild
else if htNowhere in HT then AttachMode := naAdd
else if htOnIndent in HT then AttachMode := naInsert;
FCutNode.MoveTo(DNode, AttachMode);
end;
end;
end;
//在复制事件中 FCutNode保存当前要复制的节点
FCutNode := treeview1.selected