The problem is that the main form is made visible by Application.Run(), so
I'd need to hack something that hides it immediately after it was shown.

I've tried something like this which looks like it works, but while running
it doesn't intecept the application's event loop.

  Application.Initialize;

  MainForm := TMainForm.CreateNew(Application);
  ReadComponentResFile('MainForm.Res', MainForm);
  MainForm.ShowModal;
  WriteComponentResFile('MainForm.Res', MainForm);
  MainForm.Release;

  Application.Run;

Bob
----- Original Message -----
From: "Chris Milham" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Wednesday, October 02, 2002 2:26 PM
Subject: RE: [DUG]: Persistent Main form


Hi,

Why not just make the main form hidden and have it create a form which you
can then treat as the program's main form?
HTH,

Chris

-----Original Message-----
From: Bob Osborn [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 2 October 2002 2:09 p.m.
To: Multiple recipients of list delphi
Subject: [DUG]: Persistent Main form


Hi All

I'm having trouble trying to instantiate the main form for an application by
reading it from a resource file.  My objective is to have the form restore
itself to the same settings as the previous session when it closed.

I don't have any problems restoring individual controls on the form by
streaming them to and from a stream file using the OnCreate and OnClose
events, but this seems an inconvenient way of doing it when I ought to be
able to restore the form in one go.

I'm able to read and write sub-forms successfully using
Read/WriteComponentResFile() and the CreateNew() class method,  but I can't
do this with the main form because it is created by Application.CreateForm()
which uses the resource file that is compiled into the .exe.  There doesn't
seem to be any way of switching TApplication's MainForm to another form and
so I can't see an easy workaround (or any workaround) -  but maybe someone
else has devised a way to do it.

My apologies if this subject has been thrashed on the list before.


Bob Osborn
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to