

OpenDialog : TOpenDialog // Open dialog variable

#Set a default program for text files mac code#
Open a text file for reading, or binary file for read/writeĭisplays a dialog for selecting a save file nameĭownload this web site as a Windows program.Įxample code : Illustrating single file selection Shows a dialog allowing the user to select a file Open a text file to allow appending of text to the endĪssigns a file handle to a binary or text file The file names are held in the returned TStrings value (see the TStringList for more on string lists).
#Set a default program for text files mac full#
This holds the full path plus file name of the a multiple file selection. This holds the full path plus file name of the selected file The selected file or files are obtained using the following properties: The key values are:Įxecute returns true if the user selected a file and hit OK. Sets the starting directory in the dialog. OpenDialog.Filter := 'Text files|*.txt|Word files|*.doc' Ībove we have allowed text and Word files as two options in the drop down list.ĭefines which (starting at 1) of the drop down filter choices will be displayed first. OpenDialog.Filter := 'Text and Word files only|*.txt *.doc' Ībove we have allowed two different file types, separated by a. After the separator, you define a mask that selects the files you want. The drop down dialog shows the description before the | separator. OpenDialog.Filter := 'Text files only|*.txt' The following example selects for text files only: The filter text is displayed in a drop down below the file name field. This allows only certain file types to be displayed and selectable. When returning from the dialog, if the user has hit OK, this property will contain the (first) selected file name, including its full path (see the first example). (Otherwise, the file name field is blank). Note that the dialog must have an anchor - here we provide the current object - self - as the anchor.īefore displaying the dialog, you are likely to configure it to your needs by setting the dialog properties. You define a TOpenDialog variable, and then assign a new TOpenDialog object to it: When using it, you would proceed along the following steps: The TOpenDialog can be configured to suit your needs. It can be defined by dragging the open dialog icon from the Dialogs tab in Delphi, or by defining a TOpenDialog variable. It is used to allow a user to select one or more files to open. Delphi Basics : TOpenDialog command Delphi Basics
