OpenDialog

Qualified name: delphivcl.OpenDialog

class OpenDialog

Bases: Component

TOpenDialog displays a file-selection dialog. TOpenDialog displays a modal Windows dialog box for selecting and opening files. The dialog does not appear at runtime until it is activated by a call to the Execute method. When the user clicks Open, the dialog closes and the selected file or files are stored in the Files property.

Methods

DefaultHandler

Provides the interface for a method that processes message records.

Execute

Displays the dialog

Attributes

ClassName

Returns the TObject.ClassName

ComObject

Specifies the interface reference implemented by the component.

ComponentCount

Returns the owned component count

ComponentIndex

Indicates the position of the component in its owner's Components property array.

ComponentState

Describes the current state of the component, indicating when a component needs to avoid certain actions.

ComponentStyle

Governs the behavior of the component.

Components

Returns an iterator over the owned components

Ctl3D

bool:

DefaultExt

Specifies a default file extension.

DesignInfo

Contains information used by the Form designer.

FileEditStyle

Determines the style of the file-selection dialog.

FileName

Files

List of selected file names.

Filter

Determines the file masks (filters) available in the dialog. The file-selection dialog includes a drop-down list of file types under the edit box. When the user picks a file type from the list, only files of the selected type are displayed in the dialog. To configure file masks at design time, click on the ellipsis marks (...) to the right of the Filter property in the Object Inspector. This opens the Filter editor. In the left column of the Filter editor, under Filter Name, type a brief description of each file type that will be available at runtime. In the right column, under Filter, type the file mask corresponding to each description. For example, the description "Text files" might appear to the left of the mask ".txt", and the description "Pascal source files" might appear to the left of the mask ".pas". Since the description appears in the drop-down list at runtime, it is often helpful to show the mask explicitly in the description (for example, "Text files (*.txt)"). To create file masks in program code, assign a value to the Filter property that consists of a description and a mask separated by a vertical bar (pipe) character. Do not include spaces around the vertical bar. For example,.

FilterIndex

Determines which filter is selected by default when the dialog opens.

Handle

int:

HelpContext

int:

HistoryList

Maintains a list of previously selected files.

InitialDir

Determines the current directory when the dialog opens.

Name

Specifies the name of the component as referenced in code.

Observers

Indicates the TObservers object added to the TComponent.

OnIncludeItem

Callable[[OFNotifyEx, bool], None]:

Options

Determines the appearance and behavior of the file-selection dialog.

OptionsEx

Augments the Options property with additional flags that determine the appearance and behavior of the file-selection dialog.

Owner

Returns the Component Owner

Tag

Stores a NativeInt integral value as a part of a component.

Title

Specifies the text in the dialog's title bar.

VCLComObject

Represents information used internally by components that support COM.

Ctl3D

bool:

DefaultExt

Specifies a default file extension. DefaultExt specifies a file extension that is appended automatically to the selected file name, unless the selected file name already includes a registered extension. If the user selects a file name with an extension that is unregistered, DefaultExt is appended to the unregistered extension. Extensions longer than three characters are not supported. Do not include the period (.) that divides the file name and its extension.

Code Examples SavePictureDialog (Delphi) TApplicationIcon (Delphi) SavePictureDialog (C++) TApplicationIcon (C++)

Type:

str

DefaultHandler(Message) None

Provides the interface for a method that processes message records. DefaultHandler is called by Dispatch when it cannot find a method for a particular message. DefaultHandler provides message handling for all messages for which an object does not have specific handlers. Descendant classes that process messages override DefaultHandler according to the types of messages they handle.

Note: In a Delphi message-handling method, calling inherited results in a call to the ancestor’s DefaultHandler method only if that ancestor does not specify a message method for the particular message being handled. Otherwise, calling inherited results in a call to the specific handler for that type of message.

Execute()

Displays the dialog

FileEditStyle

Determines the style of the file-selection dialog. (Obsolete.) FileEditStyle is maintained for compatibility with older versions of the VCL. It has no effect.

Type:

FileEditStyle

Files

List of selected file names. Files is a string list that contains each selected file name with its full directory path. (To let users select multiple file names, set the ofAllowMultiSelect flag in Options.) Use properties and methods for string lists to traverse this list of files and read individual items. The example below assigns the list of files in Files to the Items property of a TListBox component.

ListBox1.Items.Assign(OpenDialog1.Files);

ListBox1->Items->Assign(OpenDialog1->Files);

Type:

Strings

Filter

Determines the file masks (filters) available in the dialog. The file-selection dialog includes a drop-down list of file types under the edit box. When the user picks a file type from the list, only files of the selected type are displayed in the dialog. To configure file masks at design time, click on the ellipsis marks (…) to the right of the Filter property in the Object Inspector. This opens the Filter editor. In the left column of the Filter editor, under Filter Name, type a brief description of each file type that will be available at runtime. In the right column, under Filter, type the file mask corresponding to each description. For example, the description “Text files” might appear to the left of the mask “.txt”, and the description “Pascal source files” might appear to the left of the mask “.pas”. Since the description appears in the drop-down list at runtime, it is often helpful to show the mask explicitly in the description (for example, “Text files (*.txt)”). To create file masks in program code, assign a value to the Filter property that consists of a description and a mask separated by a vertical bar (pipe) character. Do not include spaces around the vertical bar. For example,

OpenDialog1.Filter := ‘Text files (.txt)|.TXT’;

OpenDialog1->Filter = “Text files (.txt)|.TXT”;

Multiple filters should be separated by vertical bars. For example,

OpenDialog1.Filter := ‘Text files (.txt)|.TXT|Pascal files (.pas)|.PAS’;

OpenDialog1->Filter = “Text files (.txt)|.TXT|Pascal files (.pas)|.PAS”;

To include multiple masks in a single filter, separate the masks with semicolons. This works both in the Object Inspector and in program code. For example,

OpenDialog1.Filter := ‘Pascal files|*.PAS;*.DPK;*.DPR’;

OpenDialog1->Filter = “Pascal files|*.PAS;*.DPK;*.DPR”;

If no value is assigned to Filter, the dialog displays all file types.

Type:

str

FilterIndex

Determines which filter is selected by default when the dialog opens. FilterIndex determines which of the file types in Filter is selected by default when the dialog opens. Set FilterIndex to 1 to choose the first file type in the list as the default, or set FilterIndex to 2 to choose the second file type as the default, and so forth. If the value of FilterIndex is out or range, the first file type listed in Filter is the default.

Type:

int

Handle

int:

HelpContext

int:

HistoryList

Maintains a list of previously selected files. (Obsolete.) HistoryList is maintained for compatibility with older versions of TOpenDialog. It is not used.

Type:

Strings

InitialDir

Determines the current directory when the dialog opens. InitialDir determines the default directory displayed in the file-selection dialog when it opens. For example, to point the dialog at the WINDOWSSYSTEM directory, set the value of InitialDir to C:WINDOWSSYSTEM. If no value is assigned to InitialDir, or if the specified directory does not exist, the initial directory is controlled by the global ForceCurrentDirectory variable. If ForceCurrentDirectory is true, the dialog opens with the current working directory displayed. Otherwise, the dialog opens with either the current working directory or the My Documents directory, depending on the version of Windows.

Type:

str

OnIncludeItem

Callable[[OFNotifyEx, bool], None]:

Options

Determines the appearance and behavior of the file-selection dialog. Use the Options property to customize the appearance and functionality of the dialog.

Type:

OpenOptions

OptionsEx

Augments the Options property with additional flags that determine the appearance and behavior of the file-selection dialog. Use the OptionsEx property to further customize the file open dialog beyond the options covered by the Options property.

Type:

OpenOptionsEx

Title

Specifies the text in the dialog’s title bar. Use Title to specify the text that appears in the file-selection dialog’s title bar. If no value is assigned to Title, the dialog has the title “Open”.

Code Examples TOpenDialogTitle (Delphi) TOpenDialogTitle (C++)

Type:

str