Check out the code:::
int nResponse = dlg.DoModal();
switch(nResponse)
{
case IDOK:
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
AfxMessageBox("Exiting Application");
break;
}
case IDCANCEL:
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
AfxMessageBox("Exiting Application : Execution Cancelled");
break;
}
}// End Switch
Now here when the dialog ends, I dont see any message boxes popping
up...whats the issue...
Kindly suggest
Thanks,
a.a.cpp
The problem is that when an MFC app's main window is destroyed, MFC notices
this and posts WM_QUIT. AfxMessageBox calls MessageBox, whose message loop
retrieves WM_QUIT and returns immediately. There are a couple of ways
around this. The usual AppWizard-generated code is:
CMyDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
If you delete the line which assigns to m_pMainWnd, MFC won't post
WM_QUIT (and set m_pMainWnd to zero) when the dialog is destroyed.
However, it's nice to have a main window, so I leave it alone and make
a call to eat the WM_QUIT following DoModal:
MSG msg;
PeekMessage(&msg,0,WM_QUIT,WM_QUIT,PM_REMOVE);
Now you can call MessageBox. See this KB article for another approach:
PRB: Windows Flash and Disappear in Dialog-Based Applications
http://support.microsoft.com/default.aspx?scid=kb;en-us;138681
--
Doug Harrison
Microsoft MVP - Visual C++
"iceColdFire" <icol...@yahoo.com> wrote in message
news:1115869732.6...@g14g2000cwa.googlegroups.com...
> Hi,
>
> Check out the code:::
>
> int nResponse = dlg.DoModal();
> switch(nResponse)
> {
> case IDOK:
> {
> // TODO: Place code here to handle when the dialog is
> // dismissed with OK
> AfxMessageBox("Exiting Application");
> break;
> }
> case IDCANCEL:
> {
> // TODO: Place code here to handle when the dialog is
> // dismissed with Cancel
> AfxMessageBox("Exiting Application : Execution Cancelled");
> break;
> }
default:
AfxMessageBox("Another EndDialog()");