Link to home
Start Free TrialLog in
Avatar of TomazB
TomazBFlag for Slovenia

asked on

How to save unknown components

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)?
Avatar of Cesario Lababidi
Cesario Lababidi
Flag of Germany image

Hi TomazB,

how do you insert the new Components at run Time ?

Parent ?
Owner  ?

Best Regards

Cesario
Hi,

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

Cesario

ASKER CERTIFIED SOLUTION
Avatar of Cesario Lababidi
Cesario Lababidi
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kretzschmar
or even registerclasses(...
Avatar of TomazB

ASKER

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?