function ComponentToString(Component: TComponent): string;
var
BinStream:TMemoryStream;
StrStream: TStringStream;
s: string;
begin
if Component.ClassType =TMemo then
TMemo(Component).Text :='';
BinStream := TMemoryStream.Create;
try
StrStream := TStringStream.Create(s);
try
BinStream.WriteComponent(Component);
BinStream.Seek(0, soFrombegin
ning);
ObjectBinaryToText(BinStream, StrStream);
StrStream.Seek(0, soFrombegin
ning);
Result:= StrStream.DataString;
finally
StrStream.Free;
end;
finally
BinStream.Free
end;
end;
function StringToComponent(AComponent:TComponent;Value: string): TComponent;
var
StrStream:TStringStream;
BinStream: TMemoryStream;
begin
StrStream := TStringStream.Create(Value);
try
BinStream := TMemoryStream.Create;
try
ObjectTextToBinary(StrStream, BinStream);
BinStream.Seek(0, soFrombegin
ning);
Result := BinStream.ReadComponent(AComponent);
finally
BinStream.Free;
end;
finally
StrStream.Free;
end;
end;
用这两个函数把整个窗体或单个的控件保存为string,然后想办法Load进来就可以了
帮助里有例子