我用 WriteComponent;读入组件的数据,用readcomponent读出,发现了几个问题,不知道改如何解决。1:如果读入一个button1,当读出并放在窗体上以后发现新的button不响应事件了。2:如果读入一个panel,发现他所包含的组件并没有保存进去。
我如果想解决这两个问题应该怎么办呢?

解决方案 »

  1.   

    d7 的例子,,你是怎么使用的。。function ComponentToString(Component: TComponent): string;var
      BinStream:TMemoryStream;
      StrStream: TStringStream;
      s: string;
    begin
      BinStream := TMemoryStream.Create;
      try
        StrStream := TStringStream.Create(s);
        try
          BinStream.WriteComponent(Component);
          BinStream.Seek(0, soFromBeginning);
          ObjectBinaryToText(BinStream, StrStream);
          StrStream.Seek(0, soFromBeginning);
          Result:= StrStream.DataString;
        finally
          StrStream.Free;    end;
      finally
        BinStream.Free
      end;
    end;
      

  2.   

    1:如果读入一个button1,当读出并放在窗体上以后发现新的button不响应事件了。写入流不能保存事件指针的,所以读出来当然也就是不响应事件了。你可以看看写进去之后的文本,没有发现有事件的属性。
      

  3.   

    to : linzhengqun(风。找工作当中)
       哪有没有办法把事件响应也保存下来啊?
      

  4.   

    2,function ReadRootComponent(Root: TComponent): TComponent;
      procedure WriteRootComponent(Root: TComponent);
    这两个似乎可以保存该组件以及它的所属的组件,但具体没有用过,自己研究一下吧。