InputQuery function
Use InputQuery to show a dialog box to get input from the user.
Declaration
function InputQuery(const ACaption: string; const APrompt: string;
MaskInput: Boolean; var Value: string): BooleanDescription
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 variant omits this argument. Omitting
the MaskInput argument is equivalent to setting it to False.
Value contains the initial text displayed in the edit control for
the dialog. The text entered by the user is also 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).
Another overloaded variant allows Arrays with String values to be passed in the APrompts and AValues arguments. They are used to create labels and edit controls on the dialog form, where the user can supply multiple values. The number of labels and edit controls on the dialog is determined by the length of the AValues array. An exception is raised when the APrompts and AValues arrays do not have the same length.
An event handler routine can be provided in the ACloseEvent argument to validate the input values, and determine if the dialog can be closed. It is signalled when the input dialog is closed by clicking the Cancel button or the Close icon on the dialog form. The handler returns an Array of String values input using the dialog.
See also
Example: inputquery.pas
Uses forms, lcltype, dialogs, controls;
procedure TryInputQuery;
var QueryResult: boolean;
userstring: string;
begin
if InputQuery ('Question', 'Type in some data', TRUE, userstring)
then ShowMessage (userstring)
else
begin
InputQuery ('Don''t be silly', 'Please try again', userstring);
ShowMessage (userstring)
end
end;An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.
