Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list from all opened forms of my software?

I want to ask the user to close all opened forms before terminate my application.

How can I automatically get a list from opened forms?

I'm using Delphi 2006, and don't using form's Auto-Create, but I'm using the auto created form's referenced var with Application.CreateForm.

My regards.

like image 766
Rafael Cruz Avatar asked Sep 23 '11 13:09

Rafael Cruz


2 Answers

Have a look at Screen.FormCount and Screen.Forms.

like image 57
Ondrej Kelle Avatar answered Oct 10 '22 18:10

Ondrej Kelle


A possible solution (I use in C#) is to store every opened form instance in a list var. For example you could have a global list named openedForms; when every form is created, form itself can add its reference to openedForms and remove it when closing.
When user tries to close your app, you could check that list count is greater than zero and, if user wants really close, you close gracefully every form instance contained in openedForms before shutting the app down.

like image 42
Marco Avatar answered Oct 10 '22 18:10

Marco