Did you ever try to close Form2? Because, when it tries to return from 
ShowModal in Form1 (by closing,) the code from TForm1.Button1Click won't be 
there anymore (destroyed in TForm2.FormCreate...)
If it works in your compiler, you may have problems porting it accross 
compilers (as from Delphi 4 to Delphi 7) since this call (ShowModal) returns to 
a not-yet cleaned-up residual memory.
It may also crash if your programm, running now in Form2, will allocate more 
memory which will overide the memory just released by Form1.Close (and this is 
unpredictable!)

... Unles, you do not have in your real program Form1.Close! - Then what would 
be the reason to have Form1.Hide after Form1.Close?

Don't forget that ShowModal returns after the form is closed, while Show 
returns as soon as the form shows on the screen.

Horia

________________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
Tuan Le
Sent: Monday, May 23, 2005 10:38 PM
To: [email protected]
Subject: RE: [delphi-en] How To close the parent form its child

Hi Horia,

Thank you very much. I have another way.

procedure TForm0.Button1Click(Sender: TObject);
begin
  Form1 :=TForm1.Create(Application);
  Form1.ShowModal;
  Form1.Release;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2 :=TForm2.Create(Application);
  Form2.ShowModal;
  Form2.Release;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  Form1.Close;
  Form1.Hide;
end;

It also works well.

Many thanks for your answer,

Tuan



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to