可以的..可以说很方便TFileStream.ReadComponentRes
TFileStream.WriteComponentRes还有两个过程 ObjectResourceToText(Input, Output:TStream);
ObjectTextToResource(...);是把frm文件 和 txt方式转化的delphi的底层处理都很巧妙,而且开源..呵呵

解决方案 »

  1.   

    nofog(nofog) :我没试验好,能详细一些吗?最好有个例程。
      

  2.   

    应该说,这已经很详细了。我手边没有delphi,
    没办法写例程。
    我只写关键地方把。TmpForm: TOutputForm;
    ...
    if OpenDialog1.Execute then
    begin
      MyStream := TFileStream.Create(OpenDialog1.FileName, fmOpenRead)
      TmpForm := TOutputForm.Create(Application);
      MyStream.ReadComponentRes(TmpForm);
      OutputForm.Free;//原来程序生成的OutputForm,free掉,换成新的
      OutputForm := TmpForm;
      OutputForm.Show;
      OutputForm.OnMouseDown := OutputForm.FormMouseDown;
       //这样为窗体 设置事件.
      MyStream.Free;
    end;
    ...//剩下的你应该 可以完成了吧
      

  3.   

    这个 filename  是  .frm文件格式的。否则会异常save方式的 我相信更好写的
    注意:
      记住在 save 一个窗体的时候,与这个窗体关联的所有事件最好设成nil
    因为下次你load进来,事件入口地址就不一样了,所以出于健壮考虑,save
    前,把事件handle设成nil
    例如:
        ...      
        OutputForm.OnMouseDown := nil;
        MyStream.WriteComponentRes(OutputForm.ClassName, OutputForm);
        OutputForm.OnMouseDown := OutputForm.FormMouseDown;//这里还要还原
        ...
      

  4.   

    楼上的兄弟我用:
    procedure TForm2.Button6Click(Sender: TObject);
    var Stream:TStream;
    begin
    //TFileStream.ReadComponentRes
    //  TFileStream.WriteComponentRes
    //ObjectResourceToText(Input,  Output:TStream);
    //  ObjectTextToResource(...);
    //  procedure WriteComponentRes(const ResName: string; Instance: TComponent
    //);
      Stream:=TFileStream.Create('d:\junqi_program\xxx.sgs',fmOpenReadWrite);
      stream.WriteComponentRes('d:\junqi_program\xxx.sgs',form2);
      stream.Free;
    end;
      成功的保存了属性文件。
    但我还想请教:当我的一部分组件旋转一定角度以后应当如何读取这个属性文件呢?
      谢谢!请留下联系方法:下个月我写完四国大战军旗程序我会送你一套的。
      (包括部分原代码)
      

  5.   

    这和旋转不旋转 没什么关系,res保存的是整个form上所有的组件的情况。。
    你只要保证组件个数不变,就行了。读取参看我上面的代码片段,[email protected]
    呵呵,多谢
      

  6.   

    nofog(nofog):我给了分但是CSDN没有生成正确的页面。当我再次对贴子进行管理的时候已经没有“给分”的连接了。但显示分数已经加给你了。