Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  135

•  TDictionary Custom Sort  3 316

•  Fast Watermark Sources  3 065

•  3D Designer  4 825

•  Sik Screen Capture  3 320

•  Patch Maker  3 535

•  Айболит (remote control)  3 637

•  ListBox Drag & Drop  2 996

•  Доска для игры Реверси  81 561

•  Графические эффекты  3 927

•  Рисование по маске  3 231

•  Перетаскивание изображений  2 613

•  Canvas Drawing  2 735

•  Рисование Луны  2 561

•  Поворот изображения  2 166

•  Рисование стержней  2 161

•  Paint on Shape  1 564

•  Генератор кроссвордов  2 226

•  Головоломка Paletto  1 764

•  Теорема Монжа об окружностях  2 215

•  Пазл Numbrix  1 682

•  Заборы и коммивояжеры  2 052

•  Игра HIP  1 279

•  Игра Go (Го)  1 225

•  Симулятор лифта  1 471

•  Программа укладки плитки  1 214

•  Генератор лабиринта  1 542

•  Проверка числового ввода  1 352

•  HEX View  1 490

•  Физический маятник  1 355

 
скрыть


Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Копировать нижние узлы TTreeView во второй TTreeView



Оформил: DeeCo

type
   {: Callback to use to copy the data of a treenode when the 
     node itself is copied by CopySubtree. 
   @param oldnode is the old node 
   @param newnode is the new node 
   @Desc Use a callback of this type to implement your own algorithm 
     for a node copy. The default just uses the Assign method, which 
     produces a shallow copy of the nodes Data property. }
   TCopyDataProc = procedure(oldnode, newnode : TTreenode);

 {: The default operation is to do a shallow copy of the node, via 
Assign. }
 procedure DefaultCopyDataProc(oldnode, newnode : TTreenode);
 begin
   newnode.Assign(oldnode);
 end;

 {-- CopySubtree 
-------------------------------------------------------}
 {: Copies the source node with all child nodes to the target treeview. 
@Param sourcenode is the node to copy 
@Param target is the treeview to insert the copied nodes into 
@Param targetnode is the node to insert the copy under, can be nil to 
  make the copy a top-level node. 
@Param CopyProc is the (optional) callback to use to copy a node. 
  If Nil is passed for this parameter theDefaultCopyDataProc will be 
used. 
@Precondition  sourcenode <> nil, target <> nil, targetnode is either 
  nil or a node of target 
@Raises Exception if targetnode happens to be in the subtree rooted in 
  sourcenode. Handling that special case is rather complicated, so we 
  simply refuse to do it at the moment. 
}{ Created 2003-04-09 by P. Below ----------------------------------------------------------------------- 
}
 procedure CopySubtree(sourcenode : TTreenode; target : TTreeview;
   targetnode : TTreenode; CopyProc : TCopyDataProc = nil);
 var
   anchor : TTreenode;
   child : TTreenode;
 begin { CopySubtree }
   Assert(Assigned(sourcenode),
     'CopySubtree:sourcenode cannot be nil');
   Assert(Assigned(target),
     'CopySubtree: target treeview cannot be nil');
   Assert((targetnode = nil) or (targetnode.TreeView = target),
     'CopySubtree: targetnode has to be a node in the target treeview.');

   if (sourcenode.TreeView = target) and
     (targetnode.HasAsParent(sourcenode) or (sourcenode =
     targetnode)) then
     raise Exception.Create('CopySubtree cannot copy a subtree to one of the ' +
       'subtrees nodes.');

   if not Assigned(CopyProc) then
     CopyProc := DefaultCopyDataProc;

   anchor := target.Items.AddChild(targetnode, sourcenode.Text);
   CopyProc(sourcenode, anchor);
   child := sourcenode.GetFirstChild;
   while Assigned(child) do
    begin
     CopySubtree(child, target, anchor, CopyProc);
     child := child.getNextSibling;
   end; { While }
 end; { CopySubtree }


 procedure TForm1.Button1Click(Sender : TObject);
 begin
   if assigned(treeview1.selected) then
     CopySubtree(treeview1.selected, treeview2, nil);
 end;







Copyright © 2004-2024 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте