Skip to main content

dxInputQuery(string,string,string,TdxInputQueryValidationProc) Method

Invokes a modal input dialog box that prompts a user to enter a string and checks if the user input is valid.

Declaration

function dxInputQuery(const ACaption: string; const APrompt: string; var AValue: string; AValidationProc: TdxInputQueryValidationProc): Boolean;

Parameters

Name Type Description
ACaption string

The caption of the invoked input dialog box.

APrompt string

The label of the displayed text editor.

AValue string

Returns the text editor’s value when a user clicks the OK button or presses the Enter key.

AValidationProc TdxInputQueryValidationProc

The procedure that validates a value entered by a user.

Returns

Type Description
Boolean

True if a user clicks the OK button or presses the Enter key. False if a user clicks the Cancel or Close button, or presses the Esc key.

Remarks

Call the dxInputQuery function to invoke a simple input dialog box that prompts a user to enter a string value. The dialog imports all look & feel settings from the TdxSkinController component if it is in an application project. If you pass a validation routine as the AValidationProc parameter, the invoked dialog box disables the OK button and ignores the Enter keystroke until a user enters a valid value into the displayed text editor.

Code Example

The following code example invokes a modal input dialog box with a text editor that should not be empty:

uses
  dxInputDialogs;  // This unit declares the dxInputQuery function
// ...

procedure TMyForm.ValidationProcedure(ValueIndex: Integer; const Value: string; var IsValid: Boolean);
begin
  if Value = '' then  // Disables the "OK" button if at least one editor value is an empty string
    IsValid := False;
end;

procedure TMyForm.cxButton1Click(Sender: TObject);
var
  AUserInput: string;
begin
  // ...
  dxInputQuery('Rename', 'New Name:', AUserInput, ValidationProcedure);
  // ...
end;

VCL Editors Library: A simple modal dialog box whose editor should not be empty

Note

If you need to display password characters instead of the actual user input, prepend an ASCII character whose number is less than 32 (for example, #31 in Delphi or /x31 in C++Builder) to the value passed as the APrompt parameter.

Displayed password characters depend on the global look & feel settings. If the native style is enabled, a modal input dialog box displays bullets as password characters. Otherwise, the dialog box displays asterisks.

Other Input Query Functions

You can call the following global functions to invoke a modal input dialog box with multiple text editors:

dxInputQuery(string,string[],string[])
Invokes a modal input dialog box that prompts a user to enter multiple text strings.
dxInputQuery(string,string[],string[],TdxInputQueryValidationProc)
Invokes an input dialog box that allows users to enter a string.
See Also