Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   General (http://www.delphipages.com/forum/forumdisplay.php?f=2)
-   -   Close a form from another form (http://www.delphipages.com/forum/showthread.php?t=218680)

meggyboy 06-12-2019 04:24 AM

Close a form from another form
 
Let's say I have two forms "Form1" and "Form2".
Form1 contains two buttons, one that creates and displays Form2 and a button to close Form2.

To create Form2 i use:
Code:

Form2: = TForm2.Create (Self);
Form2.Show;

How do I close Form2 from Form1 without getting an access violation?

rojam 06-12-2019 12:43 PM

Is Form2 guaranteed to exist when you close Form1? Can Form2 be closed on its own? How many instances of Form2 can be open at the same time?

The answer to these questions will determine the best solution on how to accomplish this.

GeoWink 06-12-2019 02:58 PM

I use the following to go to a form

with TDataForm.Create(Self) do
try
ShowModal;
finally
Release;
end;

To go back to the calling form I use

ModalResult := mrOK;

ModalResult can be different values depending on what happens in Form 2.

George


All times are GMT. The time now is 06:11 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.