InputQuery (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example requires a button and a label on the form. When you click the button, the input box displays. If you choose OK, the string that appears in the edit box of the dialog box displays as the caption of the label on the form. If you choose Cancel, the dialog box closes and the caption of the label remains unchanged.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  NewString: string;
  ClickedOK: Boolean;
begin
  NewString := 'Default String';
  ClickedOK := Dialogs.InputQuery('Input Box', 'Prompt', NewString);
  if ClickedOK then            { NewString contains new input string. }
    Label1.Caption := NewString;
end;

Uses