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
Files Operation
Language
Delphi 2.x
Views
93
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   
2   constructor TFrmPersistent.Create(AOwner: TComponent);
3   begin
4     if FileExists('Persistent.xGS') then
5     begin
6       inherited CreateNew(AOwner);
7       ReadComponentResFile('Persistent.xGS', self);
8       self.Visible := false;
9       FormCreate(self);
10    end
11    else
12      inherited Create(AOwner);
13  end;
14  
15  procedure TFrmPersistent.FormDestroy(Sender: TObject);
16  begin
17    WriteComponentResFile('Persistent.xGS', self);
18  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