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
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
Behalf Of [EMAIL PROTECTED]
Sent: Monday, May 23, 2005 11:31 PM
To: [email protected]
Subject: RE: [delphi-en] How To close the parent form its child


By the way, if Form1 is the main form, the previous code will close the
program
as well. To avoid that use Hide instead Close:

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

Also, now the Form1 is hidden and there is no way to close the program from
the
screen. To achieve this use in Form2:

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Form1.Close;
end;

But when Form3 was not the main form, this code:

procedure TForm3.Button1Click(Sender: TObject);
begin
  Form2 :=TForm2.Create(Application);
  Form2.Show;
  Close;
end;

works very well.

Horia


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








-----------------------------------------------------
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