Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SAVE TCOMPONENTLIST

Posted on 2002-05-29
3
Medium Priority
?
178 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 1200 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

604 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