 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
xubo Guest
|
Posted: Wed May 25, 2005 3:07 am Post subject: How to know the second Form closed?? |
|
|
Hello:
there are two forms in my application--Form1 and Form2. In Form1, Form2
is dynamically created!
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Form2 = new TForm2(this);
Form2->Show();
}
my question is when Form2 is closed, how should Form1 knows it and delete
Form2? because only one instance of Form2 is allowed.
Thanks!!
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed May 25, 2005 6:37 am Post subject: Re: How to know the second Form closed?? |
|
|
xubo wrote:
| Quote: | my question is when Form2 is closed, how should Form1 knows it and delete
Form2? because only one instance of Form2 is allowed.
|
That you were already told lately in the language group.
To repeat it:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if( !Form2 )
Form2 = new TForm2( this );
Form2->Show();
}
We will suppose that you mean by 'closed' deleted.
As the global variable Form2 is checked you should
set it to NULL as soon as Form2 is deleted. You can do that
in the OnClose() eventhandler of Form2.
void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
Form2 = NULL;
Action = caFree;
}
Hans.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|