Testing, if form exists/fr
Parfois, une fiche peut être lancée depuis plusieurs endroits dans un programme. Si elle existe déjà, il suffit de la placer en avant-plan, sinon elle doit être créée.
La façon la plus simple est celle-ci :
if (MyForm = nil) then Application.CreateForm(TMyForm, MyForm);
MyForm.Show;Utiliser CloseAction := caFree; dans l'événement OnClose de la fiche.
procedure TMyForm.Formclose(Sender: Tobject; var Closeaction: Tcloseaction);
begin
CloseAction := caFree;
MyForm := nil;
End;Cette méthode provient des discussions dans le forum.
Avertissement: Cette méthode a des limitations :
- A tout moment, il ne doit pas y avoir plus d'une instance de la classe de cette fiche (la variable MyForm devient incohérente sinon).
- La référence à toute forme de cette classe devrait être enregistrée dans cette unique variable globale.
From the Free Pascal wiki, page "Testing, if form exists/fr", as the Internet Archive kept it on 2025-01-23, last changed on 2020-02-29. 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.
Edited on wiki.freepascal.org by 2 people, 2016–2020
From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.
| When | Who | What changed |
|---|---|---|
| E-ric | Created page | |
| Trev | Fixed syntax highlighting (minor) |
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
