From: Alexander on
As the title says. An application shows a modal dialog (about box,
options, whatever). The application is terminated by the user (via an
icon in the system tray) but the modal dialog stays open.

I can't understand why. What is going on in the main app (dialog
based)? Shouldn't it all be dismissed?

Thank you all.
From: Joseph M. Newcomer on
You have to make sure you cannot terminate an app that has a modal dialog displayed. For
example, in many programs I've used, if there is a modal dialog, an attempt to close it
says "There is a dialog pending, please close it". The fact that the tray icon allows the
Close to take place is either (a) erroneous programming because it should not have been
enabled or (b) erroneous programming because OnClose was called even though a modal dialog
was up.

There was a discussion here within the last year of how to detect that a modal dialog is
up, but I don't have a reference to it. I cheated; I derived all my modal dialogs from a
dialog superclass that had a DoModal method that set a flag, because I didn't know the
technique discussed (I also could handle my own MessageBox invocations, but not any that
came from within MFC or other libraries, and the general solution would solve that)
joe

On Thu, 24 Apr 2008 23:00:25 -0700 (PDT), Alexander <the44secs(a)yahoo.com> wrote:

>As the title says. An application shows a modal dialog (about box,
>options, whatever). The application is terminated by the user (via an
>icon in the system tray) but the modal dialog stays open.
>
>I can't understand why. What is going on in the main app (dialog
>based)? Shouldn't it all be dismissed?
>
>Thank you all.
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Alexander on
Hmmm... it is not difficult to modify the system tray menu to be
disabled when a modal is up... but, still, it seems somehow
unintuitive that modals can hang around if the owner is closing...
after all, the owner doesn't really close, it simply disappears from
sight and lurks around until the modal is dismissed.




On Apr 25, 4:31 pm, Joseph M. Newcomer <newco...(a)flounder.com> wrote:
> You have to make sure you cannot terminate an app that has a modal dialog displayed.  For
> example, in many programs I've used, if there is a modal dialog, an attempt to close it
> says "There is a dialog pending, please close it".  The fact that the tray icon allows the
> Close to take place is either (a) erroneous programming because it should not have been
> enabled or (b) erroneous programming because OnClose was called even though a modal dialog
> was up.
>
> There was a discussion here within the last year of how to detect that a modal dialog is
> up, but I don't have a reference to it.  I cheated; I derived all my modal dialogs from a
> dialog superclass that had a DoModal method that set a flag, because I didn't know the
> technique discussed (I also could handle my own MessageBox invocations, but not any that
> came from within MFC or other libraries, and the general solution would solve that)
>                                         joe
>
> On Thu, 24 Apr 2008 23:00:25 -0700 (PDT), Alexander <the44s...(a)yahoo.com> wrote:
> >As the title says. An application shows a modal dialog (about box,
> >options, whatever). The application is terminated by the user (via an
> >icon in the system tray) but the modal dialog stays open.
>
> >I can't understand why. What is going on in the main app (dialog
> >based)? Shouldn't it all be dismissed?
>
> >Thank you all.
>
> Joseph M. Newcomer [MVP]
> email: newco...(a)flounder.com
> Web:http://www.flounder.com
> MVP Tips:http://www.flounder.com/mvp_tips.htm

From: Tom Serface on
I would just send a close message to the dialog from an OnClose() handler in
mainframe (assuming it's just a hidden main dialog in your application). If
you use SendMessage() it will wait for the message to be processed before
returning. Of course, this doesn't guarantee that the dialog will close,
but there aren't many good reasons for it to say open in cases like that.

Question: If the dialog is modal, how is the users exiting the program? If
it's from a right click menu or something like that you could also disable
the Exit menu item based on any dialogs being displayed.

Tom

"Alexander" <the44secs(a)yahoo.com> wrote in message
news:093ac858-29c4-42f6-8f8f-a7f0cbc461ba(a)q1g2000prf.googlegroups.com...
> As the title says. An application shows a modal dialog (about box,
> options, whatever). The application is terminated by the user (via an
> icon in the system tray) but the modal dialog stays open.
>
> I can't understand why. What is going on in the main app (dialog
> based)? Shouldn't it all be dismissed?
>
> Thank you all.

From: Alexander on
Thanks Tom.

Yes, the app is dialog based (modal in itself) and, off it, a second
modal dialog is created (say, an about box). The problem is not "not
being" able to get around it, I can and have. The reason I post is
because I was wondering what is the logic of (the system?) closing an
application without closing dependent windows.....


On Apr 25, 11:00 pm, "Tom Serface" <tom.nos...(a)camaswood.com> wrote:
> I would just send a close message to the dialog from an OnClose() handler in
> mainframe (assuming it's just a hidden main dialog in your application).  If
> you use SendMessage() it will wait for the message to be processed before
> returning.  Of course, this doesn't guarantee that the dialog will close,
> but there aren't many good reasons for it to say open in cases like that.
>
> Question: If the dialog is modal, how is the users exiting the program?  If
> it's from a right click menu or something like that you could also disable
> the Exit menu item based on any dialogs being displayed.
>
> Tom
>
> "Alexander" <the44s...(a)yahoo.com> wrote in message
>
> news:093ac858-29c4-42f6-8f8f-a7f0cbc461ba(a)q1g2000prf.googlegroups.com...
>
> > As the title says. An application shows a modal dialog (about box,
> > options, whatever). The application is terminated by the user (via an
> > icon in the system tray) but the modal dialog stays open.
>
> > I can't understand why. What is going on in the main app (dialog
> > based)? Shouldn't it all be dismissed?
>
> > Thank you all.