unit Utreeform;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, ugentree,
Vcl.StdCtrls;
type
TForm2 =
class(TForm)
Memo1: TMemo;
lblComponents: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
function CreateNodes: TNode;
end;
var
Form2: TForm2;
Root: TNode;
myFirstNode: TNode;
mySecondNode: TNode;
MyThirdNode: TNode;
implementation
{$R *.dfm}
function TForm2.CreateNodes: TNode;
var
Data: TNodeData; Node: TNode;
begin
Root.AddSubNode(
nil,TNode.Create(Root,CompareStr,'
TButton'));
Root.AddSubnode(
nil,TNode.Create(Root,CompareStr,'
TEdit'));
//Data.KeyStr := 'TEdit';
Root.AddSubnode(
nil,TNode.Create(Root,CompareStr,'
TGrid'));
//Node := TNode.Create(CompareStr);
//Data.KeyStr := 'TGrid';
Root.AddSubnode(
nil,TNode.Create(Root,CompareStr,'
TComboBox'));
Node := TNode.Create(Root,CompareStr,'
Zusätzlich');
Node.AddSubNode(Root,TNode.Create(Root,CompareStr,'
TPanel'));
Node.AddSubnode(Root,TNode.Create(Root,CompareStr,'
TTree'));
Node.AddSubnode(Root,TNode.Create(Root,CompareStr,'
TListbox'));
Result := Node;
end;
procedure TForm2.FormCreate(Sender: TObject);
var i: Integer; D: TNodeData; N: TNode;
begin
N:=CreateNodes();
Memo1.Lines.Add(N.Caption);
//Zusätzlich
//Memo1.Lines.Add(N.Parent.Caption); //Standard
//Ausgabe muss später rekursiv erfolgen
for i := 0
to N.Count-1
do
begin
Memo1.Lines.Add(N.Nodes[i].Caption);
//auch hier rekursiv,
//N.Nodes enthält das zuletzt formulierte,
//N.Parent.Nodes das vorherige
end;
Memo1.Lines.Add(N.Parent.Caption);
for i := 0
to N.Parent.Count-1
do
begin
Memo1.Lines.Add(N.Parent.Nodes[i].Caption);
end;
end;
initialization
Root := TNode.Create(
nil,CompareStr,'
Standard');
finalization
end.