Board index » cppbuilder » Transfer Data Between 2 Forms With Same Name

Transfer Data Between 2 Forms With Same Name


2005-05-01 07:54:18 AM
cppbuilder93
I have a Form in my program that I create and display using, ShapesForm =
new TShapesForm(Application); ShapesForm->ShowModal(); The form has a
button that when clicked will create and open a second version of the form
and display it with the same ShapesForm = new TShapesForm(Application);
ShapesForm->ShowModal(); I use the forms as data entry dialog boxes. When
done entering data in the top dialog box I need to close/delete the second
top form and transfer the data to the first form which is on the bottom.The
problem I have is that the forms use the same name ShapesForm so I am not
sure how to distinguish between the first and second version of ShapesForm?
I need a way to copy data from ShapesForm2 to ShapesForm1 before I delete
ShapesForm2. How can I do this?
Thanks
Larry
 
 

Re:Transfer Data Between 2 Forms With Same Name

I was sent the answer directly. I need to create a local version of the
form.
Thanks
Quote


 

Re:Transfer Data Between 2 Forms With Same Name

"LarryJ" < XXXX@XXXXX.COM >wrote:
Quote
I was sent the answer directly. I need to create a local version of the
form.
No you don't. All you have to do is change the way that you're
allocating the form so that the original form is the Owner of
both modal forms. That way you can delete the first instance
without destroying the second instance *and* from inside the
second instance, to access members of the original form, all
you have to do is cast the Owner to the original form type.
For example:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ShapesForm = new TShapesForm( this );
}
Then inside TShapesForm when you allocate another instance:
pShapes = new TShapesForm( Owner );
and inside the second instance:
TForm1 *pForm = dynamic_cast<TForm1*>( Owner );
pForm->ShapeForm->Close();
pForm->SomeMember = something;
Note that the ShapesForm doesn't get deleted. Add an OnClose
event and set the Action parameter to caFree so that the form
will delete itself when it's closed.
~ JD
 

{smallsort}