Saving runtime created form.

Is it possible to save a form to a blob stream or file that was created during runtime?

I have tried saving the form using WriteComponent but I get an error when trying to read it back in. (Class TEdit not found).

I would like the user to be able to create a form during runtime and save it then allow them to load it back in later.
LVL 2
CalvinDayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

edeyCommented:
Did you remember to include stdctrls in the unit you used to load the component?


GL
Mike
0
CalvinDayAuthor Commented:
Yes it was already there.
0
CalvinDayAuthor Commented:
Isn't this supposed to work?

procedure TForm1.Button2Click(Sender: TObject);
var
  fs:TFileStream;
begin
  fs:=TFileStream.Create('c:\test.dfm', fmCreate);
  fs.WriteComponent(Form1);
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  fs:TFileStream;
  Form:TForm;
begin
  fs:=TFileStream.Create('c:\test.dfm', fmOpenRead);
  Form:=fs.ReadComponent(nil) as TForm;
  Form.Show;
end;


This gives me the error:
Class TForm1 not found.
0
rwilson032697Commented:
Which one? The read or the write?

Classes which are read/written to streams like this need to be registered, like this:

registerClasses([TEdit, T...]);

Cheers,

Raymond.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CalvinDayAuthor Commented:
Excellent Raymond!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.