Sign in Join
Wiki copytemporary

user should not be able to close form/fr: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: user should not be able to close form/fr

OldNewLine
1+Vous pouvez utiliser l'événement OnCloseQuery de la fiche pour notifier quand la fiche va être fermée. Commencez par ajouter dans le gestionnaire à partir de l'inspecteur d'objets. La variable CanClose détermine s'il faut (valeur *true*) ou non (valeur *false*) quitter la fiche. Mettre CanClose à false empêche la sortie de la fiche (par exemple pour obliger la validation ou l'annulation d'une saisie), c'est une assez mauvaise idée car cela bloque définitivement le programme.
2+
3+Dans l'exemple ci-dessous, il est interdit de sortir de la fiche si rien n'est saisi dans le contrôle d'édition Edit1.
4+
5+Example:
6+
7+``` pascal
8+uses
9+ Forms, ...;
10+
11+ ...
12+
13+procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
14+begin
15+ CanClose := (Length(Edit1.Text) > 0);
16+end;
17+
18+ ...
19+
20+```
21+
22+---
23+*From the Free Pascal wiki, page "user should not be able to close form/fr", as it stood on 2020-03-03 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](/wiki-contact).*

Back to history