InputQuery (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses 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

#include <dialogs.hpp>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  UnicodeString NewString = "Default String";
  if (InputQuery("Input Box", "Prompt", NewString))
    // NewString has been changed by the user, who clicked OK.
    Label1->Caption = NewString;
}

Uses