Solved

How to save unknown components

Posted on 2001-06-07
5
197 Views
Last Modified: 2010-04-06
I am saving the whole form trough:

var Stream: TMemoryStream;

  Stream:=TMemoryStream.Create;
  Stream.WriteComponent(MyForm);
  Stream.Seek( 0, soFromBeginning );  
  Stream.SaveToFile('MyForm.dfm');
  Stream.free;

But if I create a component in run time and instance of such component doesn't exists on this form in design time,
then I can't load back this form from file to app. I get error saying that such component doesn't exist.
How to save form with new components (I would like to load components to form in run time from dll's or so)?
0
Comment
Question by:TomazB
  • 3
5 Comments
 
LVL 8

Expert Comment

by:Cesario
ID: 6163146
Hi TomazB,

how do you insert the new Components at run Time ?

Parent ?
Owner  ?

Best Regards

Cesario
0
 
LVL 8

Expert Comment

by:Cesario
ID: 6163151
Hi,

// To save the Form you can use  this Procedure
WriteComponentResFile('MyForm.dfm',MyForm);

Cesario

0
 
LVL 8

Accepted Solution

by:
Cesario earned 100 total points
ID: 6163155


you must register the components in the OnCreateEvent in you main Form:

<<I get error saying that such component doesn't exist. >>
Procedure tMyform.CreateForm ( ....);
Begin
  RegisterClass ( TNewcomponent );
  RegisterClass ( ......        );
End;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6163214
or even registerclasses(...
0
 

Author Comment

by:TomazB
ID: 6180331
Yes, now I don't need to put "dumy" components on form to save and reload it. Is it possible to register component by it's name later - if I want to create instance of new component. like from dll?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 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