[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

In Delphi 2006, how can I silently close all modal forms of a Delphi Application?

Asked by waeberd in Delphi Programming, Windows Programming

Tags: Delphi Modal Forms Abort Application

Hello,

In Delphi 2006, I'm trying to write a routine to "automatically minimize the application after n minutes of inactivity".

Before minimizing the application, I need all modal forms to be closed. My problem here: how can I be sure that closing the modal forms is done in a silent way?

Typically, If there's a FormCloseQuery-Handler  asking some "are you sure?" questiondialogs, the form won't be closed, causing trouble  when re-maximizing the application (-> lockup because the modal form has the focus, but is invisible).

I've added the code snippet I use in the main form to abort all modal forms.

I need a more robust solution, any help is appreciated.

Thanks, Daniel
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TMyMainForm.AbortModalForms;
var
  i: integer;
  frm: TForm;
begin
  for i := Screen.FormCount - 1 downto 0 do
  begin
    frm := Screen.Forms[i];
    if (fsModal in frm.FormState) then
    begin
      frm.ModalResult := mrAbort;
    end
  end;
end;
[+][-]11/04/09 12:59 AM, ID: 25737512Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 02:39 AM, ID: 25737986Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 02:41 AM, ID: 25738002Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625