Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Thread Tools Display Modes
Old 06-12-2019, 04:24 AM
meggyboy meggyboy is offline
Junior Member
Join Date: Oct 2013
Location: Sweden, Klippan
Posts: 1
Send a message via Skype™ to meggyboy
Default 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?

Last edited by meggyboy; 06-12-2019 at 04:47 AM.
Reply With Quote
Old 06-12-2019, 12:43 PM
rojam rojam is offline
Senior Member
Join Date: Jun 2015
Posts: 200

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.
Reply With Quote
Old 06-12-2019, 02:58 PM
GeoWink GeoWink is offline
Senior Member
Join Date: Jan 2001
Posts: 885

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.

Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

All times are GMT. The time now is 05:05 AM.

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