Link to home
Start Free TrialLog in
Avatar of cvbmn
cvbmn

asked on

LOAD and SAVE *.DFM

LOAD and SAVE *.DFM

How to load and save FORMs in DFMs at runtime ?

Thanks.
Avatar of bes67
bes67

Class TFileStrem has methods to load and save components. There are ReadComponent and WriteComponent and ReadComponentRes and WriteComponentRes. Besides, there are WriteComponentResFile and ReadComponentResFile functions.
When you are ready to save your form just write

WriteComponentResFile(‘Form1.frm’, self);

where first parameter is a filename and path of a form file (where to save) and a second parameter is a reference to form (use self while calling from form method)

When you want to load previously saved form do something like this

AForm:=(AFormClass).CreateNew(AOwner); // creates a form instance
ReadComponentResFile(aFileName, AForm); // reads properties

Hope this will help
Avatar of cvbmn

ASKER

WriteComponentResFile is not working  ! ! ! ! !

I tried :

WriteComponentResFile('Form.frm', TForm(Componentlist[0]));

But it doesn't work.
Because Form.frm size is 1kb, but on that form are about 30-40 components.

I exactly need dfm TEXT file to save form.
Or info with RICHEDIT where is DFM TEXT code of choosen FORM.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of bes67
bes67

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