[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Dialogs' (#lcl)

PromptForFileName

Displays a file open or save dialog to select a file name for the operation.

Declaration

Source position: dialogs.pp line 738

function PromptForFileName(

  var AFileName: string;

  const AFilter: string = '';

  const ADefaultExt: string = '';

  const ATitle: string = '';

  const AInitialDir: string = '';

  AIsSaveDialog: Boolean = False

):Boolean;

Arguments

AFileName

  

Updated to contain the file name selected in open or save dialog.

AFilter

  

File masks used in the dialog.

ADefaultExt

  

Default file extension for the file name selected in the dialog.

ATitle

  

Title displayed on the dialog.

AInitialDir

  

Initial directory displayed in the dialog.

AIsSaveDialog

  

True to create a save dialog, False to create an open dialog.

Function result

True if a file name was selected using the dialog.

Description

PromptForFileName is a Boolean function used to display an Open or Save dialog using the values passed as arguments to the routine. It creates a TOpenDialog or a TSaveDialog instance for use in the routine. The AIsSaveDialog argument determines which dialog class is used in the routine.

Argument values are assigned to the corresponding properties in the dialog class. The Execute method in the dialog class is called to perform file selection or creation as needed, and its return value is used as the return value for the routine. The return value is True when the Execute method for the dialog class returns True.

AFilename contains the initially selected file name in the dialog, and is updated with the value selected using the dialog. A default value is not provided for the argument. If the dialog returns True, the FileName property in the dialog class is assigned to the AFileName argument.

AFilter contains file masks that can be selected in the dialog. The default value is an empty string ('') and causes the all files mask ('*.*' or '*') to be used. See TFileDialog.Filter for more information about the notation allowed in the argument.

ADefaultExt contains the file extension used for the file name selected in the routine. The default value for the argument is an empty string ('') and indicates that a default file extension is not used. See TFileDialog.DefaultExt for more information about default extensions.

ATitle contains the caption displayed on the dialog. The default value is an empty string ('') and allows the default value provided by the dialog class to be used.

AInitialDir indicates the initial directory when the dialog is displayed. The default value is an empty string ('') and causes the current directory in the application to be used as the initial directory in the dialog.

See also

TFileDialog.FileName

  

Contains the UTF-8-encoded name for a file chosen using the dialog.

TFileDialog.DefaultExt

  

Contains the default extension for file names in the dialog.

TFileDialog.Filter

  

A string which contains possible filename filters (e.g. .doc, .xmp, .pas etc).

TFileDialog.FilterIndex

  

This property sets which file filter is the default.

TFileDialog.InitialDir

  

Contains the initial directory displayed when the dialog is opened.

TFileDialog.Title

  

The Title or Caption displayed for the dialog.

TOpenDialog

  

Implements a File / Open dialog used to select one or more files on the local file system.

TSaveDialog

  

TSaveDialog - Dialog for saving the current buffer to a file.

TCommonDialog.Execute

  

Displays the dialog and captures the result.


Version 3.2 Generated 2024-02-25 Home