delphi中的DFM中存有窗体的初始化数据,有没有再次利用的的可能?比如,在不重新打开程序的情况下,回复窗体的一切到刚打开程序时的样子.
貌似Memo(还是RichEdit?)就可以save自己的一切状态到某个文件并也可load出来,也不知是怎么用的.

解决方案 »

  1.   


    procedure TForm1.ReloadForm;
    var
      i : Integer;
    begin
      Hide;
      try
        for i:=ComponentCount-1 downto 0 do
          RemoveComponent(Components[i]);
        InitInheritedComponent(Self, TForm);
      finally
        Show;
      end;
    end;
      

  2.   

    现在找到了
    (Read|write)ComponentRes(file);
    4个函数
    但都不知道怎么用.
      

  3.   

    啊,搞错了是三个:
    ReadComponentRes
    ReadComponentResFile
    WriteComponentResFile
      

  4.   

    我尝试用它们读取单个控件,很OK.但是读取整个Form时会说"Button1 already exists."