ICloseQueryEventArgs.CloseReason

Fore Syntax

CloseReason: FormCloseReason;

Fore.NET Syntax

CloseReason: Prognoz.Platform.Interop.Forms.FormCloseReason;

Description

The CloseReason property returns the reason of form closing.

Example

For the example to be executed, a form should exist. The specified procedure is set for the form as a handler of the OnCloseQuery event.

    Sub FormOnCloseQuery(Sender: Object; Args: ICloseQueryEventArgs);
    Var
        b: Boolean;
    Begin
        If Args.CloseReason = FormCloseReason.UserClosing Then
            b := WinApplication.ConfirmationBox(
                "Closing this form should result in the loss of all unsaved data. Are you sure you wish to close the form?");
            Args.Allowed := b;
        End If;
    End Sub FormOnCloseQuery;

When the event occurs, the cause of form closing is determined. If the user tries to close the form, the confirmation dialog is shown on the screen. If the Yes button is pressed in the dialog, the form is closed.

See also:

ICloseQueryEventArgs