unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, VirtualTrees,shellapi;
type ttreedata =
record
fcaption:pchar;
fcolumnn1:pchar;
text1: pchar;
text2:pchar;
text3:pchar;
end;
type
TForm5 =
class(TForm)
vst: TVirtualStringTree;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
insertnodebutton: TButton;
exitbutton: TButton;
insertdatabutton: TButton;
getdatabutton: TButton;
procedure vstClick(Sender: TObject);
procedure getdatabuttonClick(Sender: TObject);
procedure exitbuttonClick(Sender: TObject);
procedure insertdatabuttonClick(Sender: TObject);
procedure insertnodebuttonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
var
ptreedata:^ttreedata;
knoten,knotenparent:pvirtualnode;
insertmode,insertdata,getdata:boolean;
benutzer:
string;
{$R *.dfm}
procedure TForm5.FormShow(Sender: TObject);
begin
insertmode:=false;
end;
procedure TForm5.insertnodebuttonClick(Sender: TObject);
begin
if not insertmode
then
begin
insertmode:=true;
insertdatabutton.Enabled:=false;
getdatabutton.Enabled:=false;
end
else
begin
insertmode:=false;
insertdatabutton.Enabled:=true;
insertdatabutton.Enabled:=true;
end;
end;
procedure TForm5.insertdatabuttonClick(Sender: TObject);
begin
if not insertdata
then
begin
insertdata:=true;
insertnodebutton.Enabled:=false;
getdatabutton.Enabled:=false;
end
else
begin
insertdata:=false;
insertnodebutton.Enabled:=true;
getdatabutton.Enabled:=true;
end;
end;
procedure TForm5.exitbuttonClick(Sender: TObject);
begin
form5.close;
end;
procedure TForm5.getdatabuttonClick(Sender: TObject);
begin
if not getdata
then
begin
getdata := true;
insertnodebutton.Enabled:=false;
insertdatabutton.Enabled:=false;
end
else
begin
getdata := false;
insertnodebutton.Enabled:=true;
insertdatabutton.Enabled:=true;
end;
end;
procedure TForm5.vstClick(Sender: TObject);
begin
if insertmode
then
begin
knoten:=vst.addchild(vst.FocusedNode);
vst.NodeDataSize:=sizeof(ttreedata);
insertmode:=false;
insertdatabutton.enabled:=true;
getdatabutton.enabled:=true;
end;
//von if insertmode ja
if insertdata
then
begin
insertdata:=false;
insertnodebutton.Enabled:=true;
getdatabutton.Enabled:=true;
knoten:=vst.FocusedNode;
vst.NodeDataSize:=sizeof(ttreedata);
ptreedata:=vst.GetNodeData(knoten);
ptreedata^.fcaption:=pchar(edit1.Text);
showmessage(ptreedata^.fcaption);
ptreedata^.text2:=pchar(edit2.Text);
ptreedata^.text3:=pchar(edit3.Text);
end;
if getdata
then
begin
getdata:=false;
insertnodebutton.Enabled:=true;
insertdatabutton.Enabled:=true;
vst.NodeDataSize:=sizeof(ttreedata);
knoten:=vst.FocusedNode;
ptreedata:=vst.GetNodeData(knoten);
edit1.Text:=string(ptreedata^.fcaption);
edit2.Text:=string(ptreedata^.text2);
edit3.Text:=string(ptreedata^.text3);
//showmessage( knotendaten^.fcaption);
end;
insertnodebutton.enabled:=true;
insertdatabutton.Enabled:=true;
getdatabutton.Enabled:=true;
end;
end.