que tal gente
tengo mi TreeView y tengo el siguiente codigo, segun yo sirve para arrastrar los nodos dentro del mismo TreeView pero lo tengo y no me deja realizar lo que quiero, alguien sabra que onda con este codigo:
Código:
procedure TfrmCuentasContables.trvCuentasDragDrop(Sender, Source: TObject;
X, Y: Integer);
var
AnItem: TTreeNode;
AttachMode: TNodeAttachMode;
HT: THitTests;
begin
if TrvCuentas.Selected = nil then
Exit;
HT := trvCuentas.GetHitTestInfoAt(X, Y) ;
AnItem := TrvCuentas.GetNodeAt(X, Y) ;
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;
TrvCuentas.Selected.
MoveTo(AnItem, AttachMode) ;
end;
end;
procedure TfrmCuentasContables.trvCuentasDragOver(Sender, Source: TObject;
X, Y: Integer; State: TDragState; var Accept: Boolean);
var
TargetNode, SourceNode : TTreeNode;
begin
TargetNode := TrvCuentas.GetNodeAt(X, Y);
//acepta arrastrar desde el mismo
If (Source = Sender) and (TargetNode <> nil) Then
begin
Accept := True;
//determina origen y destino
SourceNode := TrvCuentas.Selected;
//Busca la cadena padre destino
while (TargetNode.Parent <> nil) and (TargetNode <> SourceNode) do
TargetNode := TargetNode.Parent;
//Si se encuentra el origen
if TargetNode = SourceNode Then
//no permine el arrastre a un nodo hijo
Accept := False;
end
else
Accept := False;
end;
espero me puedan ayudar
muchas gracias