[Overview][Types][Classes][Procedures and functions][Index] | Reference for unit 'LazDialogs' (#lcl)

# TLazarusFileDialogForm.HandleCloseQuery

Event handler for an OnCloseQuery event notification.

## Declaration

Source position: lazdialogs.pas line 39

`public procedure TLazarusFileDialogForm.HandleCloseQuery(`
`Sender: TObject;`
`var CanClose: Boolean`
`);`

## Arguments

`Sender` |  | Component performing the event notification.
`CanClose` |  | Indicates if the Lazarus dialog form can be closed.

## Description

HandleCloseQuery is a procedure used as the event handler for the OnCloseQuery event notification. It is assigned in the Initialize method.

HandleCloseQuery ensures that the Lazarus dialog form can in fact be closed, and updates the value in FileName when needed. It sets the value in the CanClose parameter to False when the modal result for the dialog form is mrCancel. No additional actions are performed in the method if the dialog form cannot be closed.

Additional actions are performed in the method to update FileName and CanClose based on the TLazFileDialogKind value used in the dialog form. For Save dialogs (where Kind is ldkSaveDesktop or ldkSavePDA), the value in the SaveEdit control cannot contain be an empty string (''). No additional actions are performed in the method when SaveEdit is empty. Otherwise, the values from the selected item in ShellTreeView, PathDelimite, and SaveEdit are combined and assigned to FileName. CanClose is also set to True.

For Open dialogs (where Kind is ldkOpenDesktop or ldkOpenPDA), the selected item in ShellListView cannot be unassigned (Nil). No additional actions are performed in the method when the selected item in ShellListView is unassigned. Otherwise, the value in FileName is set to the path and file name for the selected item in ShellListView. CanClose is also set to True.

For other dialog kinds, the selected item in ShellTreeView cannot be unassigned (Nil). No additional actions are perform when the selected item in ShellTreeView is unassigned. Otherwise, the path information for the selected item is stored in FileName. CanClose is also set to True.

## See also

TLazarusFileDialogForm.Initialize |  | Creates and positions child controls on the Lazarus dialog form.
TLazarusFileDialogForm.FileName |  | File name for the selected file in the Lazarus dialog form.
TLazarusFileDialogForm.ShellTreeView |  | Shell tree view control for the Lazarus dialog form.
TLazarusFileDialogForm.ShellListView |  | Shell list view control for the Lazarus dialog form.