[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] |
Use InputQuery to show a dialog box to get input from the user.
Source position: dialogs.pp line 771
function InputQuery( |
const ACaption: string; |
const APrompt: string; |
MaskInput: Boolean; |
var Value: string |
):Boolean; |
const ACaption: string; |
const APrompt: string; |
var Value: string |
):Boolean; |
const ACaption: string; |
const APrompts: array of string; |
var AValues: array of string; |
ACloseEvent: TInputCloseQueryEvent = Nil |
):Boolean; |
ACaption |
|
The caption for the dialog box. |
APrompt |
|
The text label displayed for the edit control on the dialog box. |
MaskInput |
|
Determines if the dialog shows * characters instead of the actual input. |
Value |
|
The initial value(s) displayed, and the modified value(s) returned from the dialog box. |
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.
ACaption |
|
The caption for the dialog box. |
APrompt |
|
The text label displayed for the edit control on the dialog box. |
Value |
|
The initial value(s) displayed, and the modified value(s) returned from the dialog box. |
ACaption |
|
The caption for the dialog box. |
APrompts |
|
Array with strings values used as labels on the input dialog. |
AValues |
|
Arrays with string values used in edit controls for the associated labels. |
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.
|
Displays a box with specified title and prompt, and accepts user input in a text box. |
|
|
Displays a Password prompt with input masking. |
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;
Version 3.2 | Generated 2024-02-25 | Home |