Solved

How to save unknown components

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
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 this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 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