The best way to handle this is to pass the desired Caption value to the constructor itself, rather than encode it to look up the value, for example:
__fastcall TfrmChooseName(TComponent *Owner, const String &ACaption) : TForm(Owner) { Caption = ACaption; }
.
frmChooseName = new TfrmChooseName(this, txtInput->Text);
Alternatively, you can set Caption after exiting the constructor, for example:
frmChooseName = new TfrmChooseName(this); frmChooseName->Caption = txtInput->Text;
source share