Delphi Pages Forums

Delphi Pages Forums (
-   General (
-   -   Close a form from another form (

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:

Form2: = TForm2.Create (Self);

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

To go back to the calling form I use

ModalResult := mrOK;

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


All times are GMT. The time now is 08:16 PM.

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