unit Hauptformular;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, Menus, OleCtrls, SHDocVw,
DB;
type
TFmHaupt =
class(TForm)
MainMenu1: TMainMenu;
Datei1: TMenuItem;
TreeView1: TTreeView;
Splitter1: TSplitter;
Panel1: TPanel;
WebBrowser1: TWebBrowser;
Panel2: TPanel;
DSTreeView: TDataSource;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
procedure FormDestroy(Sender: TObject);
procedure FillTreeView(TheView : TTreeView; TheData : TDataSet);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
type
TTView =
Record
ID : Integer;
ParentID : Integer;
end;
PView = ^TTView;
var
FmHaupt: TFmHaupt;
implementation
uses HauptformularDM;
{$R *.dfm}
//-08-Aug-2005--------------------------------------------------------------------------------------
// Form Create
procedure TFmHaupt.FormCreate(Sender: TObject);
begin
FillTreeView(TreeView1, DMHaupt.QHauptTreeView);
end;
//-08-Aug-2005--------------------------------------------------------------------------------------
//
procedure TFmHaupt.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
//
end;
//-08-Aug-2005--------------------------------------------------------------------------------------
//
procedure TFmHaupt.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
//
end;
//-08-Aug-2005--------------------------------------------------------------------------------------
//
procedure TFmHaupt.FormDestroy(Sender: TObject);
begin
//
end;
//-09-Aug-2005--------------------------------------------------------------------------------------
//
procedure TFmHaupt.FillTreeView(TheView: TTreeView; TheData: TDataSet);
procedure MoveToParentNode(TheNode: TTreeNode);
var x : Integer;
begin
for x := 0
to TreeView1.Items.Count-1
do begin
if Assigned(TreeView1.Items[x].Data)
then begin
if PView(TreeView1.Items[x].Data).ID = PView(TheNode.Data).ParentID
then begin
TheNode.MoveTo(TreeView1.Items[x], naAddChild);
Break;
end;
end;
end;
end;
var Root,AktNode : TTreeNode;
i : Integer;
begin
DMHaupt.QHauptTreeView.First;
Root := TTreeNode.Create(TreeView1.Items);
Root.Text := '
Test';
Root.Data :=
nil;
while not DMHaupt.QHauptTreeView.EOF
do begin
AktNode := TTreeNode.Create(TreeView1.Items);
AktNode.Data := new(PView);
PView(AktNode.Data).ID := DMHaupt.QHauptTreeView.FieldByName('
ID').AsInteger;
PView(AktNode.Data).ParentID := DMHaupt.QHauptTreeView.FieldByName('
ParentID').AsInteger;
DMHaupt.QHauptTreeView.Next;
end;
for i := 0
to TreeView1.Items.Count-1
do begin
if Assigned(TreeView1.Items[i].Data)
then begin
if PView(TreeView1.Items[i].Data).ParentID <> 0
then MoveToParentNode(TreeView1.Items[i]);
end;
end;
end;
end.