PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app 
Author Message
 PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app

Hi all,

I created an MFC dialog-based app that makes some
processing after the main dialog has closed. It mainly
catches exceptions and must display the exception
text in a message box.

If I don't run the main dialog box (in IDE using "set
instruction" debug commands) and directly go to
the instruction that generates the exception, the
message box is displayed. Otherwise a beep occurs
and the message box is NOT displayed :/...

What's wrong here ? How can I display a message
box AFTER the main dialog box has run and closed ?
What does prevent my app from doing so ? Is it a
feature of MFC ?

Thank you for any suggestion.

--
Vince C.



Sat, 18 Jan 2003 03:00:00 GMT  
 PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app


Fri, 19 Jun 1992 00:00:00 GMT  
 PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app
I found something: if I comment out the following line after my
dialog box is declared:

CMyDialog dlg;
// m_pMainWnd = &dlg;
dlg.DoModal();
...
AfxMessageBox( [...] );

the message box is displayed !

That means no main window is defined nor assigned in the MFC
sense. The app works gently as it should however. The lack of
m_pMainWnd seems harmless...

--
Vince C.

------


Quote:
> Hi all,

> I created an MFC dialog-based app that makes some
> processing after the main dialog has closed. It mainly
> catches exceptions and must display the exception
> text in a message box.

> If I don't run the main dialog box (in IDE using "set
> instruction" debug commands) and directly go to
> the instruction that generates the exception, the
> message box is displayed. Otherwise a beep occurs
> and the message box is NOT displayed :/...

> What's wrong here ? How can I display a message
> box AFTER the main dialog box has run and closed ?
> What does prevent my app from doing so ? Is it a
> feature of MFC ?

> Thank you for any suggestion.

> --
> Vince C.



Sat, 18 Jan 2003 03:00:00 GMT  
 PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app
Vince:

Yes, you cannot show another modal dialog (or message box, same thing)
after the main window is closed. I'm not sure what the impact of simply
not telling MFC that the main dialog is the main window, but I would
suggest putting the message box in the OnOK or OnCancel handler of the
dialog.

BTW, the same thing happens in DocView applications. There you can put
the messagebox/dialogin the WM_CLOSE handler for the main window.

HTH,

David Wilkinson

===============

Quote:

> I found something: if I comment out the following line after my
> dialog box is declared:

> CMyDialog dlg;
> // m_pMainWnd = &dlg;
> dlg.DoModal();
> ...
> AfxMessageBox( [...] );

> the message box is displayed !

> That means no main window is defined nor assigned in the MFC
> sense. The app works gently as it should however. The lack of
> m_pMainWnd seems harmless...

> --
> Vince C.

> ------


> > Hi all,

> > I created an MFC dialog-based app that makes some
> > processing after the main dialog has closed. It mainly
> > catches exceptions and must display the exception
> > text in a message box.

> > If I don't run the main dialog box (in IDE using "set
> > instruction" debug commands) and directly go to
> > the instruction that generates the exception, the
> > message box is displayed. Otherwise a beep occurs
> > and the message box is NOT displayed :/...

> > What's wrong here ? How can I display a message
> > box AFTER the main dialog box has run and closed ?
> > What does prevent my app from doing so ? Is it a
> > feature of MFC ?

> > Thank you for any suggestion.

> > --
> > Vince C.



Sat, 18 Jan 2003 03:00:00 GMT  
 PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app
Thank you David. Do you know the reasons of that fact ?

--
Vince C.



Quote:
> Vince:

> Yes, you cannot show another modal dialog (or message box, same thing)
> after the main window is closed. I'm not sure what the impact of simply
> not telling MFC that the main dialog is the main window, but I would
> suggest putting the message box in the OnOK or OnCancel handler of the
> dialog.

> BTW, the same thing happens in DocView applications. There you can put
> the messagebox/dialogin the WM_CLOSE handler for the main window.

> HTH,

> David Wilkinson

> ===============


> > I found something: if I comment out the following line after my
> > dialog box is declared:

> > CMyDialog dlg;
> > // m_pMainWnd = &dlg;
> > dlg.DoModal();
> > ...
> > AfxMessageBox( [...] );

> > the message box is displayed !

> > That means no main window is defined nor assigned in the MFC
> > sense. The app works gently as it should however. The lack of
> > m_pMainWnd seems harmless...

> > --
> > Vince C.

> > ------


> > > Hi all,

> > > I created an MFC dialog-based app that makes some
> > > processing after the main dialog has closed. It mainly
> > > catches exceptions and must display the exception
> > > text in a message box.

> > > If I don't run the main dialog box (in IDE using "set
> > > instruction" debug commands) and directly go to
> > > the instruction that generates the exception, the
> > > message box is displayed. Otherwise a beep occurs
> > > and the message box is NOT displayed :/...

> > > What's wrong here ? How can I display a message
> > > box AFTER the main dialog box has run and closed ?
> > > What does prevent my app from doing so ? Is it a
> > > feature of MFC ?

> > > Thank you for any suggestion.

> > > --
> > > Vince C.



Sat, 18 Jan 2003 03:00:00 GMT  
 PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app


Fri, 19 Jun 1992 00:00:00 GMT  
 PBM: Message box not displayed after main dialog box is closed in MFC dialog-based app

Quote:

>Hi all,

>I created an MFC dialog-based app that makes some
>processing after the main dialog has closed. It mainly
>catches exceptions and must display the exception
>text in a message box.

>If I don't run the main dialog box (in IDE using "set
>instruction" debug commands) and directly go to
>the instruction that generates the exception, the
>message box is displayed. Otherwise a beep occurs
>and the message box is NOT displayed :/...

>What's wrong here ? How can I display a message
>box AFTER the main dialog box has run and closed ?
>What does prevent my app from doing so ? Is it a
>feature of MFC ?

>Thank you for any suggestion.

See this KB article:

http://support.microsoft.com/support/kb/articles/Q138/6/81.asp?LN=EN-...

--
Doug Harrison [VC++ MVP]
Eluent Software, LLC
http://www.eluent.com
Tools for Visual C++ and Windows



Sat, 18 Jan 2003 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. HELP: activex control in dialog box in mfc user dll (dialog not launching)

2. Problem Closing UI thread dialog boxes from main app

3. displaying dialog box with my main window..

4. Displaying Dialog Box On the Main Window

5. displaying dialog box with my main window..

6. Not showing the main dialog box

7. ToolBar in Dialog Box (not main frame)

8. dialog can not be closed when I close sdi main window

9. key RETURN to execute a button (NOT to close the Dialog box)

10. Displaying message/dialog box before EnableShellOpen call

11. ESC character closes dialog box in MFC Appl

12. Icon not display on dialog box

 

 
Powered by phpBB® Forum Software