Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-09

Multiple copies of same form

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Timothy Groves

I would like to write an app that has the following properties:

1)  A main form exists, one of which is spawned at program start;
2)  Additional copies of the main form may be spawned;
3)  The program exits only when no copies of the main form are in existence.

I've tried a few things when spawning additional forms, such as form.Create, but when I close the *first* form spawned, *all* such forms are destroyed. I also tried Application.CreateForm, but that doesn't seem to do anything. Google has failed me, as well.

What's my best option for this?

Reply by email

Hans-Peter Diettrich
to Timothy Groves
Show quoted text 10 lines
I would like to write an app that has the following properties: 1) A main form exists, one of which is spawned at program start; 2) Additional copies of the main form may be spawned; 3) The program exits only when no copies of the main form are in existence. I've tried a few things when spawning additional forms, such as form.Create, but when I close the *first* form spawned, *all* such forms are destroyed.

That's the specified behaviour: the first created form becomes Application.MainForm, and the program terminates when exactly that form is closed.

I also tried Application.CreateForm, but that doesn't seem to do anything. Google has failed me, as well. What's my best option for this?

I'd keep a dummy MainForm hidden, and count the instances of the other forms.

DoDi

Reply by email

Mattias Gaertner
to Hans-Peter Diettrich
Show quoted text 15 lines
Timothy Groves schrieb: > I would like to write an app that has the following properties: > > 1) A main form exists, one of which is spawned at program start; > 2) Additional copies of the main form may be spawned; > 3) The program exits only when no copies of the main form are in > existence. > > I've tried a few things when spawning additional forms, such as > form.Create, but when I close the *first* form spawned, *all* such forms > are destroyed. That's the specified behaviour: the first created form becomes Application.MainForm, and the program terminates when exactly that form is closed.

No. The first form created by Application.CreateForm becomes the MainForm. Except for splash and mdi forms.

> I also tried Application.CreateForm, but that doesn't > seem to do anything. Google has failed me, as well. > > What's my best option for this?
Create forms with
Form1:=TForm1.Create(Application);

or:

I'd keep a dummy MainForm hidden, and count the instances of the other forms.

Mattias

Reply by email