RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Dialogs.InputQuery Function

Displays an input dialog box that lets the user enter a string, double, or integer.

Pascal
function InputQuery(const ACaption: string; const APrompt: string; var Value: string): Boolean;
C++
Boolean InputQuery(const AnsiString ACaption, const AnsiString APrompt, AnsiString Value);

Dialogs

Call InputQuery to bring up an input dialog box ready for the user to enter a string, double, or integer in its edit box. 

ACaption is the caption of the dialog box. 

APrompt is the text that prompts the user to enter input in the edit box. 

Value is the value that appears in the edit box when the dialog box first appears and which returns the value that the user enters. 

AMin is the minimum value the user can enter into the edit box. 

AMax is the maximum value the user can enter into the edit box. 

Decimals does nothing. 

Increment controls the amount by which the value in the spin control changes when the user clicks the up or down arrow. (It has no effect on values that the user types). 

InputQuery returns true if the user chooses OK, and false if the user chooses Cancel or presses the Esc key. 

If a default value should be used when the user cancels out of the dialog, use InputBox instead.  

C++ Examples: 

 

/*
This example uses a button and a label on the form. When the
user clicks the button, the input box displays. If the user
chooses OK, the string that appears in the edit box of the
dialog box displays as the caption of the label on the form.
If the user chooses Cancel, the dialog box closes and the
caption of the label remains unchanged.
*/
#include <dialogs.hpp>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  AnsiString NewString = "Default String";
  Label1->Caption = NewString;
  if (InputQuery("Input Box", "Prompt", NewString))
    // NewString has been changed by the user, who clicked ok
    Label1->Caption = NewString;
}

 

Delphi Examples: 

{
This example uses a button and a label on the form. When the
user clicks the button, the input box displays. If the user
chooses OK, the string that appears in the edit box of the
dialog box displays as the caption of the label on the form.
If the user chooses Cancel, the dialog box closes and the
caption of the label remains unchanged.
} 
procedure TForm1.Button1Click(Sender: TObject);
var
  NewString: string;
  ClickedOK: Boolean;
begin
  NewString := 'Default String';
  Label1.Caption := NewString;
  ClickedOK := Dialogs.InputQuery('Input Box', 'Prompt', NewString);
  if ClickedOK then            { NewString contains new input string }
    Label1.Caption := 'The new string is ''' + NewString + '''';
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!