Solved

How to save unknown components

Posted on 2001-06-07
5
193 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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