[Lazarus] Multiple copies of same form

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sat Sep 14 03:08:46 CEST 2013


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.

>  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





More information about the Lazarus mailing list