
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.