Solved

SAVE TCOMPONENTLIST

Posted on 2002-05-29
3
173 Views
Last Modified: 2010-04-04
SAVE TCOMPONENTLIST

How to save context of TComponentList ?

Thanks.
0
Comment
Question by:zuipo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 7042293
Please be more precise on "context".
Any tComponent is derived from TPersistend and can save itself to a file. The .dfm files are nothing but the saved Forms.
0
 

Author Comment

by:zuipo
ID: 7042405
In my TComponentList are different components including TForm. Do you have solution how to save it in file ?

Thanks.
0
 
LVL 9

Accepted Solution

by:
ITugay earned 300 total points
ID: 7043995
hi all,

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;



procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  L: TStringList;
  I: Integer;
begin
  L := TStringList.Create;
  for I := 0 to Panel1.ControlCount - 1 do
    L.Add(ComponentToString(Panel1.Controls[I]));
  L.SaveToFile('F:\comps.txt');
  L.Free;
end;

-----
Igor.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
select query - oracle 16 101
Dynamically Created Query 3 69
Sending files from  idTcpServer Socket to idTcpClient 2 52
Multi-layered image in FireMonkey 9 67
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question