Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to stream forms to and from disk Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
20-Oct-02
Category
VCL-Forms
Language
Delphi 2.x
Views
60
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

I have a form that creates an advanced SQL string and I am trying to stream the 
entire form (TAdvanced) to disk in order to save the state of the form, and then be 
able to easily recall it later without having to decode the SQL string. However, 
after successfully (I think) streaming it to disk, I get the error "A component 
named PageControl1 already exists". I have tried all kinds of variations on this, 
but there always seems to be some conflict - either TAdvanced can't be assigned to 
TAdvanced or the current, or others. Any suggestions would be appreciated. Do I 
need to manually iterate through the components of the form and write each one in 
turn to the stream?

Answer:

I would use Read/ WriteComponentResFile with code similar to:

1   constructor TFrmPersistent.Create(AOwner: TComponent);
2   begin
3     if FileExists('Persistent.xGS') then
4     begin
5       inherited CreateNew(AOwner);
6       ReadComponentResFile('Persistent.xGS', self);
7       self.Visible := false;
8       FormCreate(self);
9     end
10    else
11      inherited Create(AOwner);
12  end;
13  
14  procedure TFrmPersistent.FormDestroy(Sender: TObject);
15  begin
16    WriteComponentResFile('Persistent.xGS', self);
17  end;



			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC