如何解决如何保存和加载 TFrame 内容?
我使用以下代码来保存和加载我的表单:
public
constructor Create(AOwner: TComponent); override;
procedure BeforeDestruction; override;
var
PreservePath: String;
constructor TMyForm.Create(AOwner: TComponent);
begin
PreservePath := ExtractFilePath(Application.ExeName) +
'Preserve';
if not DirectoryExists(PreservePath) then
CreateDir(PreservePath);
PreservePath := PreservePath + '\';
if FileExists(PreservePath + ClassName + '.sav') then
begin
CreateNew(AOwner,0);
with TFileStream.Create(PreservePath + ClassName + '.sav',fmOpenRead or fmShareDenyWrite) do
try
ReadComponent(Self);
finally
Free;
end;
end;
end;
procedure TMyForm.BeforeDestruction;
begin
inherited;
with TFileStream.Create(PreservePath + ClassName + '.sav',fmCreate) do
try
WriteComponent(self);
finally
Free;
end;
end;
它对 Form 工作正常,但是当尝试对 TFrame
执行相同操作时,它不起作用,因为它没有 CreateNew
过程。如何保存和加载此框架?特别是如果它包含动态创建的控件。
Windows 7、Delphi 7。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。