Some dialogs commonly used in Lazarus applications. Look at the Procedures as well as the Classes
Constants to define the types of message dialogs.
Constants to define possible buttons on a dialog.
Set of button messages for dialogs
A "set" constant to show a Yes, a No and a Cancel button on a messagedialog.
A "set" constant to show a Yes, a No and a Cancel button on a messagedialog.
A "set" constant to show a Yes and a No button on a messagedialog.
A "set" constant to show a Yes and a No button on a messagedialog.
A "set" constant to show an OK and a Cancel button on a messagedialog.
A "set" constant to show an OK and a Cancel button on a messagedialog.
A "set" constant to show an Abort, a Retry and an Ignore button on a messagedialog.
A "set" constant to show an Abort, a Retry and an Ignore button on a messagedialog.
A constant array used to convert the kind of message buttons to the kind of BitButton.
This array gives you for each possible button type in a messagebox the corresponding kind of BitButton.
For instance MsgDlgBtnToBitBtnKind[mbYes] has the value of bkYes.
It is the reverse of BitBtnKindToMsgDlgBtn.
A constant array used to convert the kind of BitButton to the kind of message buttons.
This array gives you for each BitButton the corresponding type of button on a message dialog. For instance BitBtnKindToMsgDlgBtn[bkOK] has the value of mbOK. It is the reverse if MsgDlgBtnToBitBtnKind.
TCommonDialog
: the base type from which other dialogs are derived
TCommonDialog: the base type from which all other dialogs are derived.

Use the "Create" method to make an instance of the dialog,

the "Execute" method to show it to the user

and the "Close" method to release it and free the used resources.
The function that actually takes care of executing the dialog
Returns True if the correct exit button was pressed
FCompStyle
- local variable holding the style
The owner of the dialog: the component that called it
A public method causing the dialog box to appear, offer the relevant choices to the user and act upon the choice
Use the execute method of a dialog to show it
and then check the result to see if the user made a valid choice and pressed the OK button.
Returns True if the user pressed the OK button
Operating system Handle for the dialog
UserChoice
- the value selected by the user
Close the dialog and return the memory used
DoShow
- the procedure that actually takes care of showing the dialog box
DoCanClose
- software emulation of the OnCanClose event
DoClose
- software emulation of the OnClose event
HandleAllocated
- returns True if a handle has been allocated
Event Handler for closing the dialog
Event Handler when dialog is able to be closed
Event handler for showing the dialog
HelpContext
- an index to the context-dependent help message for this dialog
The width of the dialog box
The height of the dialog box
The Title or Caption to be shown at the top of the dialog box
TFileDialog
: allows selection of a file from the current directory.

TFileDialog : allows selection of a file from the current directory.

This is also the base class for the Open and Save (As) dialogs

GetFilterIndex
- returns the Index value for the filename filter
SetFileName
- specifies the filename in the file dialog
SetFilter
- specifies the Filter for use in filename searching
SetHistoryList
- specifies a list of strings that have been used in searching
DoTypeChange
- perform the code for the OnTypeChange event
Stringlist which stores the names of the selected files.
HistoryList
- stringlist containing the names of files recently accessed
IntfFileTypeChanged
- interface method for file type change
Sets the default file extension for the file dialog box.
String to store the name of the file chosen by the user.
A string which contains possible filename filters (eg .doc, .xmp, .pas etc).
This is a string which contains the filters a user can choose from.

The available filters and their description are separated by pipe symbols.

To set this property during runtime assign a value like: "All files|*.*|Lazarus Project files|*.lpr"
This property sets which file filter is the default.
This property sets which file filter is the default. For example, set this property to 2 to set the second filter as default.
Set the directory the dialog shows on opening.
Event handler when the Help button is clicked
Event Handler when the selected file type is changed
TOpenOption
- a list of possible options which can be used in OpenDialog

TOpenOption - a list of possible options which can be used in OpenDialog

    ofReadOnly,
        ofOverwritePrompt, // if selected file exists shows a message, that file
                           // will be overwritten
        ofHideReadOnly,    // hide read only file
        ofNoChangeDir,     // do not change current directory
        ofShowHelp,        // show a help button
        ofNoValidate,
        ofAllowMultiSelect,// allow multiselection
        ofExtensionDifferent,
        ofPathMustExist,   // shows an error message if selected path does not exist
        ofFileMustExist,   // shows an error message if selected file does not exist
        ofCreatePrompt,
        ofShareAware,
        ofNoReadOnlyReturn,// do not return filenames that are readonly
        ofNoTestFileCreate,
        ofNoNetworkButton,
        ofNoLongNames,
        ofOldStyleDialog,
        ofNoDereferenceLinks,// do not expand filenames
        ofEnableIncludeNotify,
        ofEnableSizing,    // dialog can be resized, e.g. via the mouse
        ofDontAddToRecent, // do not add the path to the history list
        ofForceShowHidden, // show hidden files
        ofViewDetail,      // details are OS and interface dependent
        ofAutoPreview      // details are OS and interface dependent

TOpenOptions
- set of TOpenOption
TOpenDialog
: open a file in the current directory, selected by File Dialog.
TOpenDialog
: open a file in the current directory, selected by File Dialog.

If the required file is not in the current directory, another directory can be selected with Select Directory
DereferenceLinks
- removes all existing referential links
CheckFile
- returns True if the nominated file meets all requirements.
CheckFileMustExist
- returns True if a file with the supplied name actually exists
A protected method which calls CheckFile for each selected file, returns True if all are OK
DoFolderChange
- execute the code for a folder change
DoSelectionChange
- execute the code for a change in selection
Options to be used for this dialog
Options to be used for the Open File dialog. A full list of available options is found in
Event triggered when the user changes the folder in the OpenDialog.
This event is called when the user changes the folder (directory) in the OpenDialog.
Note: changing the folder will also trigger the OnSelectionChange event.
Event triggered when the user changes the selection made in the OpenDialog.
This event is triggered when the user changes the selected file in the OpenDialog.
Note: When the user changes the folder OnSelectionChange will be called first.
TSaveDialog
- Dialog for saving the current buffer to a file
Save Dialog: invoked when the application requires to save a file.

If the file is already open or a filename has been specified, then the current buffer is written to that file;

if no file is specified, the Save File As dialog is invoked and the buffer is saved to that file.
Select Directory Dialog
Select Directory Dialog: allows the user to select a directory when the directory structure is displayed as a tree.
TDirSelDlg TDirectoryEdit
TColorDialog
- dialog for selecting a colour to use in graphics and text
Colour Dialog: presents a palette of colours to allow the user to select the required colour for text or graphics.

Call the Execute function to show the color dialog.
Internal property to store the value of the chosen color.
You can set the caption of the color dialog by changing this property.
Color
the colour that is selected by the dialog (a value may have been pre-set and may be accepted, but a new value can be chosen)
When the Color dialog has been shown and the user pressed OK, the FColor property contains the chosen color.
TColorButton
- a SpeedButton designed to be used with the Color dialog, allowing a colour to be selected for text or graphics

TColorButton - a SpeedButton designed to be used with the Color dialog, allowing a colour to be selected for text or graphics

To use the ColorButton, first select the ColorButton icon from the Component Palette and place it on the Form Designer in the location you want it to occupy, then place a TColorDialog on the Form Designer, give it a name (or accept the default name) and select this named dialog as the ColorDialog property in the Object Inspector for the ColorButton.

The default appearance of the ColorButton is a rectangle containing a colour; if you wish to include a caption beside the block of colour, you may need to adjust the size of the control to accommodate the text, and you can then enter some text in the Caption property of the ColorButton; this text will appear next to the colour block.

After compilation, at runtime the ColorButton is visible with a default or preselected ButtonColor in the block, and any optional caption beside it; the ColorDialog is not visible until the ColorButton is clicked, when the ColorDialog pops up and offers a choice of colours, either from a list or a palette, and if the user makes a selection and closes the dialog by pressing OK, the ColorButton will display the colour that was chosen in the ColorDialog

Note that in the context of ColorButton, properties with the name ButtonColor refer to the colour that has been selected and is displayed in the colour block; properties entitled Color without 'Button' attached refer to the colour of the control itself, usually the same as the background or the default button face colour

ShowColorDialog
- method for displaying the Colour dialog
GetGlyphSize
- returns the value of the size for glyphs on the button
DrawGlyph
- draw the glyph on the button face
BorderWidth
- the width of the button's borders
ButtonColorAutoSize
- returns True if the block displaying button colour is to be autosized
ButtonColorSize
- the size of the button colour block
ButtonColor
- the colour that has been selected by the ColorDialog and is displayed in the button
The ColorDialog that opens when the button is activated
Caption
- a string that can be placed beside the block of colour
The Color of the control itself, ie the parts that are not the colour display block; edges, background etc
OnColorChanged
- event handler for a change in button colour
An enumerated list of constants to set the options of a Font dialog.
A set of options for font dialogs
Font Dialog
Font Dialog: opens a dialog allowing choice of a font for textual displays
A private method which sets the font of the dialog.
ApplyClicked
- software emulation of the OnApplyClicked event
Property to store the chosen font.
MinFontSize
- minimum size for the font
MaxFontSize
- maximum size for the font
A set of options available from TFontDialogOptions
OnApplyClicked
- event handler for a click on the Apply button (ie the user wishes to apply the selected font)
The text displayed as an example in the preview pane of the dialog, using the selected font
As a standard, the preview plane of the dialog
shows all letters both in uppercase and lowercase.
A list of possible options which can be used in Find-dialogs.
A list of possible options which can be used in Find-dialogs.
If set the "Down" radiobutton is selected.
This option will be set when the user presses "Find Next"
If set the "Match case" checkbox is hidden from the Find dialog
If set the "Whole word" checkbox is hidden from the Find dialog
If set the "Up" and "Down" radiobuttons are hidden from the Find dialog
This flag is set when the user checks the "Match case" checkbox.
If set the "Match case" checkbox is disabled in the Find dialog
If set the "Up" and "Down" radiobuttons are disabled in the Find dialog
If set the "Whole word" checkbox is disabled in the Find dialog
This flag is set if only the first occurence of the search string is to be replaced with the replace string.
This flag is set if all occurences of the search string are to be replaced with the replace string.
This flag is set when the user checks the "Whole word" checkbox.
If set the dialog will display a help button.
A set of TFindOption
TFindDialog
- a dialog used for finding text within the current editor or text buffer
Opens a dialog box allowing the user to enter text for searching, for example in a text editor.

As TFindDialog is the parent class for the TReplaceDialog,
it contains definitions for the Replace method,
but the Replace option does not actually appear when the dialog is displayed:
you need to use TReplaceDialog to do that
FFindForm
- local variable holding the form used for the Find dialog
FOnReplace
- local variable identifying the event handler for replacing
FOnFind
- local variable identifying the event handler for finding
FOptions
- local variable holding the set of current options
FOnHelpClicked
- local variable identifying the help event handler
FReplaceText
- local variable holding the Replace text
FFindText
- local variable containing the text to be found
FindClick
- method for execution when the Find button is clicked
HelpClick
- method to execute when the Help button is clicked
CancelClick
- method to execute when the Cancel button is clicked
UpdatePosition
- method to update the position of the cursor within the document in which text is being sought
DoCloseForm
- execute the code for closing the Find/Replace dialog form
Find
- software emulation of the OnFind event
Help
- software emulation of the OnHelpClicked event
Replace
- software emulation of the OnReplace event
CreateForm
- function result returns the form that was created
SetFormValues
- specifies the values for the form
GetFormValues
- finds the values for the form
ReplaceText
- the text string that is to be substituted for the Find text
OnReplace
- event handler for replacing text
CloseDialog
and returns its resources
The Left side of the dialog display
The Position of the dialog display
the Top of the dialog display
FindText
- the text string that the dialog will try to find
The current Options for the seeking and replacing process
OnFind
- event handler for a click on the Find button
OnHelpClicked
- event handler for a click on the Help button
A dialog allowing the user to replace text
The dialog appears and offers boxes for the user to enter text for searching and text to replace it,
for example while editing a file or large piece of text.

A number of buttons appear, offering the choice to replace this instance, find next, replace all
ReplaceClick
- code to execute when the Replace button is clicked (replace just the current instance)
ReplaceAllClick
- code to execute when the Replace All button is clicked (replace all remaining instances)
Base class for TPrinterSetupDialog and TPageSetupDialog.
Enumerated type for range of pages to print.
Print all pages.
Print the selected range of pages.
Print the selection of individual pages.
Print the current page.
Enumerated type for available options for print dialogs
A set of options for the print dialog
TCustomPrintDialog
- base class for TPrintDialog.
If True, printer will be asked to Collate pages if multiple copies are produced
Number of Copies of the document
FromPage
- first page of selection for printing
MinPage
- smallest number of page in print range
MaxPage
- highest number of page in print range
The seet of Options for printing
PrintToFile
- if True, printing is spooled to a file instead of the printer
PrintRange
- the range of pages for printing
ToPage
- the final page number in the range for printing
Message Dialog
Show a message to the user and receive his response.

There are four versions of this function.

The first version displays a dialog with the standard caption,

the second, third and fourth versions enable you to set the caption.

The third version allows for a Default button;

the fourth version contains a help keyword instead of using context-based help.

If the first 'Caption' argument is missing, no caption is shown on the box.

This is the most complete and elaborate of the message dialogs,

and allows the programmer considerable control over the appearance of the dialog box.

The arguments defining the kind of box and its icon are types rather than integer constants,

and the buttons can be specified as a set in square brackets

eg [mbRetry, mbIgnore, mbAbort, mbCancel].

The HelpCtx argument allows the use of Context Help

The return value from the Function is the identity of the button pressed,

expressed as an integer (see the constant definitions in TControl

, [mrNone..mrAll]).
The result of this function is the button the user pressed to close the dialog.
The result of this function is the button the user pressed to close the dialog.
This is expresed as an integer
The message to be shown.
The message shown to the user.
The type of dialog to be shown
The DlgType parameter indicates the type of dialog to show.
You can choose from
mtWarning, mtError, mtInformation, mtConfirmation or mtCustom.
Determines the buttons shown on the messagedialog
Buttons indicate which set of button captions have to be shown on the dialog.
You can choose from predefined sets:
mbAbortRetryIgnore,
mbOKCancel,
mbYesNo, mbYesNoCancel,
or you can make your own set.
HelpCtx is used to specify which topic from the help should be shown.
HelpCtx is used to specify which topic from the help should be shown.
Used to set the caption of the messagedialog.
Sets the caption of the messagedialog shown by this function.
An extended MessageDlg function.
This function performs the same function as the MessageDlg

function.
It has been extended with parameters to place the dialog on a certain postion on the screen instead of in the centre of the screen.
The MessageDlgPos function does not enable you to choose the caption of the dialog.
The result of this function is the button the user pressed to close the dialog.
The result of this function is the button the user pressed to close the dialog.
The message to be shown.
The message shown to the user.
The type of dialog to be shown
The DlgType parameter indicates the type of dialog to show.
You can choose from
mtWarning, mtError, mtInformation, mtConfirmation or mtCustom.
Determines the buttons shown on the messagedialog
Buttons indicate which buttons have to be shown on the dialog.
You can choose from predefined sets:
mbAbortRetryIgnore,
mbOKCancel,
mbYesNo,
mbYesNoCancel,
or you can make your own set.
HelpCtx is used to specify which topic from the help should be shown.
HelpCtx is used to specify which topic from the help should be shown.
X specifies the position of the left side of the dialog
X specifies the position of the left side of the dialog.
Y specifies the position of the top side of the dialog
Y specifies the position of the top side of the dialog
An extended MessageDlgPos function.
This function enables you to specify a Helpfile which has to be shown when the user presses F1.
The result of this function is the button the user pressed to close the dialog.
The result of this function is the button the user pressed to close the dialog.
The message to be shown.
The message shown to the user.
The type of dialog to be shown
The DlgType parameter indicates the type of dialog to show.
You can choose from
mtWarning, mtError, mtInformation, mtConfirmation or mtCustom.
Determines the buttons shown on the messagedialog
Buttons indicate which buttons have to be shown on the dialog.
You can choose from predefined sets:
mbAbortRetryIgnore,
mbOKCancel,
mbYesNo,
mbYesNoCancel,
or you can make your own set.
HelpCtx is used to specify which topic from the help should be shown.
HelpCtx is used to specify which topic from the help should be shown.
X specifies the position of the left side of the dialog
X specifies the position of the left side of the dialog
Y specifies the position of the top side of the dialog
Y specifies the position of the top side of the dialog
The Helpfile that has to be shown when the user presses F1
The name of the helpfile to be shown when the user presses F1 in the dialog.
Show a question to the user and get a response
QuestionDlg has the same functionality as MessageDlg

except for the parameter Buttons which is of a different type.

You can define your own captions and return values of this function.

Buttons is a list of TModalResult (defined as constants [mrNone..MrYesToAll] in

) and strings.

For each TModalResult a button is created.

To set a custom caption, add a string after a button.

The default TModalResults defined in controls.pp (mrNone..mrLast)

doesn't need a caption. The default captions will be used.
The result of this function is the button the user pressed to close the dialog.
The result of this function is the button the user pressed to close the dialog.
Used to set the caption of the question dialog.
Set the caption of the question dialog shown by this function.
The question to be shown.
The question the user has to answer.
The type of dialog to be shown in fact which icon will be shown.
An array of return values and caption for the buttons on the question dialog.
Buttons is defined as a array of const.
This means you can define any number of buttons to be shown.
If your array consists of only predefined return values like mrOK and mrCancel,
the standard OK and Cancel buttons will be shown.

The strength of this function is however that you can fill the array like:
[400, 'Yes!!!', 401, 'Are you mad?', 402, 'My mistake'],
which will create a dialog with three buttons;
the captions of the buttons will be the strings given in the array.

The return value of the function will be 400, 401 or 402,
depending on whether the user clicked the 'Yes!!!', the 'Are you mad?' or the 'My mistake' button.
HelpCtx is used to specify which topic from the help should be shown.
HelpCtx is used to specify which topic from the help should be shown.
Show Message
Procedure ShowMessage (const Msg: string);

The simplest message dialog: takes a simple string as argument,

displays it in a stereotyped box,

and waits for a mouse-click or enter-key event

before returning to the calling routine or program.

This is a modal procedure call,

that is the box is displayed, receives focus,

and does not relinquish focus until the OK box is clicked or otherwise selected.
A string constant containing the message to be shown.
A string constant containing the message to be shown.
Shows a message assembled from a format string and an array of arguments.
This procedure is an extension to the ShowMessage

procedure. The parameters it takes are the same as the Format function.
The format string
The parameters to be inserted in the message.
Shows a message box at a given screen position.
Shows a message box at a given screen position.
A string constant which is the message to ne shown.
The horizontal position of the messagebox.
The vertical position of the messagebox.
Use InputQuery to show a dialog box to get some input from the user

Two versions of this function which displays a prompt and expects user input of textual data;

The first includes a MaskInput boolean argument
which determines whether the user input is masked out by asterisks in the text-input box
(like during entry of a password),
the second omits this property.

The text entered by the user is returned in the variable argument 'Value'. The function result is a boolean which returns TRUE if the OK button was pressed, or FALSE if the box was closed by any other mechanism (such as clicking the 'Close' icon on the top title bar).

Omitting the MaskInput argument is equivalent to setting it FALSE.

Returns True of OK button was pressed, False if Cancel was pressed or abnormal exit
Result is True if the user pressed OK or hit RETURN in the dialog box. If the user pressed Cancel or the dialog was closed without pressing a button the result will be false.
The caption for the dialogbox
The text asking the user for his input.
Determines if the dialog shows *s or the actual input.
Set MaskInput to true if you want to hide the input and display asterisks.
The value the user entered.
When the DialogBox is shown the text in the Editbox will be Value.
This string can be altered or amended by the user.
When ENTER is pressed or OK clicked, Value will be the (possibly amended) text from the Editbox.
Displays a box with defined title and prompt, and expects user input in a text box

. A default string can optionally be displayed in the text box. The user-entered or default string is returned as the function result.

If the user selects the OK button, the text in the text box is returned. If the user selects the Cancel button, the default string is returned.

The result of this function is the string the user entered in the editbox or the default string

.
The caption for the dialogbox

.
The text asking the user for his input

.
Default value for dialog box
The value of the editbox in the dialog will have this value.
Password Box
PasswordBox: a specialised form of the InputQuery.

The editbox on the dialog box will mask the input.
The only parameters are aCaption and aPrompt.

Behaves very similarly to the InputQuery function with MaskInput = TRUE;
the difference is that the password that was typed in is returned as the result of the function (like InputBox).
The string the user entered.
The caption for the dialog
A prompt to ask for the users input.
List of options available when selecting a directory
Set of directory selection options
A function that allows to user to select a directory.
This function will show a dialog which allows the user to select the required directory when the directory structure is displayed as a tree.

Under Windows the caption from the resulting dialog cannot be set, but the label above the directory tree will have this value.

There are two version of this function, the second one having the ability to indicate whether hidden folders should be shown as well.
A boolean indicating if the user pressed OK.
A boolean indicating if the user selected a directory and pressed OK.
A constant which sets the caption of the shown dialog.
A constant which sets the caption of the shown dialog.
The directory the dialog should start in.
The directory the dialog should start in.
If a valid directory is given, the selected directory in the tree will be set to this directory.
A variable which on exit contains the selected directory.
A variable which on exit contains the selected directory.
A boolean constant indicating whether hidden folders should be shown too.
A boolean constant indicating whether hidden folders should be shown too.
Register the components used in the current application, so that they can be recognised
DefaultTitle
- returns the default title for a dialog
CustomColors
- a customised list of colours that can be used instead of the system-supplied list
GetDisabledPattern
- returns a BitMap with a disabled pattern