[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Freeing/Creating forms from other form

Posted on 1998-09-21
3
Medium Priority
?
144 Views
Last Modified: 2010-04-06
I have an application in which there are 5 forms: a main menu which always exists and four forms that get created and destroyed from the main menu form.  

On the main menu there are 5 buttons: Quit which destroys the four other forms, and one button for each of the four forms to display the associated form. When the user clicks on one of the button to show one of the four forms, it must check if the form is already created. If it is it shows it otherwise it first has to create it. When the Quit button on the main menu is clicked, the four other forms are destroyed (gracefully).

What is the best way of doing this ?

Thank you.

0
Comment
Question by:skylinka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 800 total points
ID: 1340512
You can use this and as soon as the forms are closed the self destroy them....

var
  newform : TForm;
begin
  newform := TForm.Create(self);
  with newform do
  try
    ShowModal;
  finally
    free;
  end;
end;

YOu can also use the button to destroy the forms.... here is an explanation

if you call SomForm.Free; the free method first checks if the forms has been destroyed, if it hasn't then it destroys it if it has then nothing happens...so ifyou have a button that frees all forms and call it Forms.Free; it will check if the forms are freed and if they are not freed then they will be destroyed(freed)...

Vik;->
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340513
You can also you TList;
Implementetion
var
  List : TList;

in Form's OnCreate() event
begin
  List := TList.Create;
end;

in Form's OnDestroy() event
begin
  List.free;  
end;

Where you create the forms....

var
  F : TForm;
begin
  F := TForm.Create(self);
  List.Add(F);
  F.Show;
end;

In the Quit Button's OnClick() event
var
 i : integer;
begin
  for i := 0 to List.Count - 1 do
    TForm(List.Items[i]).Free;
end;

Vik ;->
0
 

Author Comment

by:skylinka
ID: 1340514
Thank you. Good idea.
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question