L
Linux2001
Unregistered / Unconfirmed
GUEST, unregistred user!
比如rocedure TForm1.Button2Click(Sender: TObject);
var
AStream:TFileStream;
I:integer;
begin
AStream:=TFileStream.Create('Save.Dat',fmCreate);
for I:=0 to PageControl1.ControlCount-1 do
if ((Controls is TPageControl) or (Controls is TToolBar)) then
AStream.WriteComponent(Controls);
AStream.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
AStream:TFileStream;
AReader:TREader;
New:TComponent;
begin
AStream:=TFileStream.Create('Save.Dat',fmOpenRead);
while AStream.Position<AStream.Size do
begin
AReader:=TReader.Create(AStream,4096);
try
AReader.Parent:=Form1;
New:=AReader.ReadRootComponent(Nil);
Form1.InsertComponent(New);
finally
AReader.Free ;
end;
end;
AStream.Free;
end;
这样的,但是保存的Save.Dat为0字节,什么都没有?我先说一下,我的ToolBar是在TPageControl上的!
var
AStream:TFileStream;
I:integer;
begin
AStream:=TFileStream.Create('Save.Dat',fmCreate);
for I:=0 to PageControl1.ControlCount-1 do
if ((Controls is TPageControl) or (Controls is TToolBar)) then
AStream.WriteComponent(Controls);
AStream.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
AStream:TFileStream;
AReader:TREader;
New:TComponent;
begin
AStream:=TFileStream.Create('Save.Dat',fmOpenRead);
while AStream.Position<AStream.Size do
begin
AReader:=TReader.Create(AStream,4096);
try
AReader.Parent:=Form1;
New:=AReader.ReadRootComponent(Nil);
Form1.InsertComponent(New);
finally
AReader.Free ;
end;
end;
AStream.Free;
end;
这样的,但是保存的Save.Dat为0字节,什么都没有?我先说一下,我的ToolBar是在TPageControl上的!