Transfer data between forms in borland c++ builder
c++builder, c++builder-2010, c++builder-xe2
Solution
The best way to handle this is to pass the desired Caption value to the constructor itself, rather than code it to hunt for the value, eg:
__fastcall TfrmChooseName(TComponent *Owner, const String &ACaption)
: TForm(Owner)
{
Caption = ACaption;
}
.
frmChooseName = new TfrmChooseName(this, txtInput->Text);
Alternatively, you can set the Caption after the constructor exits, eg:
frmChooseName = new TfrmChooseName(this);
frmChooseName->Caption = txtInput->Text;
Problem
I designed two forms in c++ builder: - TfrmMain - TfrmChooseName In TfrmMain class I have button named btnNext. when btnNext is clicked, code below runs and creates new TfrmChooseName. ``` frmChooseName = new TfrmChooseName(this); this->Hide(); frmChooseName->ShowModal(); this->Show(); delete frmChooseName; frmChooseName = NULL; ``` also in TfrmMain I have TEdit control named txtInput. In costructor of TfrmChooseName I want to get text of txtInput and set it as a caption of form but access volation error occured! I also made both classes friend!