Sign in Join
Wiki copytemporary

Testing, if form exists/de

Manchmal kann eine Form von mehreren Stellen in einem Programm gestartet werden. Wenn sie bereits vorhanden ist, muss sie nur nach vorn gebracht werden. Wenn nicht, muss sie erstellt werden.

Diese Methode wird nur benötigt, wenn die Form nicht automatisch erstellt wird (es sollte aber unter Hauptmenü -> Projekt -> Formulare zu finden sein).

Der einfachste Weg ist:

pascal
if (MyForm = nil) then Application.CreateForm(TMyForm, MyForm);
MyForm.Show;

Verwenden Sie Closeaction: = caFree in OnClose-Ereignis des Formulars z.B so:

pascal
procedure TMyForm.Formclose(Sender: Tobject; var Closeaction: Tcloseaction);
begin
  CloseAction := caFree;
  MyForm := nil;
End;

From the Free Pascal wiki, page "Testing, if form exists/de", as it stood on 2020-02-29 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.