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

I want to ask the user to close all open forms before completing my application.

How can I automatically get a list from open forms?

I am using Delphi 2006 and not using the Auto-Create form, but I am using the automatically generated var form with Application.CreateForm .

Sincerely.

+6
source share
4 answers
+17
source

A possible solution (I use in C #) is to store each instance of the open form in the var list. For example, you might have a global list called openForms; when each form is created, the form itself can add its own link to openForms and delete it when closing.
When a user tries to close your application, you can verify that the number of lists is greater than zero, and if the user really wants to close, you gracefully close each instance of the form contained in openForms before closing the application.

+3
source

I use

 Main.MDIChildCount >0 

for children from

+1
source
 var i:integer; begin with Application do for i:=0 to componentcount-1 do if components[i] is TMyCustomForm //your form class here, or simply TForm then showmessage(components[i].Name); end; 

Shows MDI and non-MDI forms.

0
source

Source: https://habr.com/ru/post/897897/


All Articles