主对话框返回IDOK后,我再创建一个对话框,domodal,可是这时候这个对话框会直接退出。请问这是怎么回事? CPngWindowDlg dlg;
m_pMainWnd = &dlg;
SetDialogBkColor(RGB(100,100,100), RGB(0, 0, 0));
int nResponse = dlg.DoModal();
PngwindowSever pngSeverDlg;
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
m_pMainWnd = &pngSeverDlg;
int nRes = pngSeverDlg.DoModal(); //Domodal后会直接退出
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
m_pMainWnd = &dlg;
SetDialogBkColor(RGB(100,100,100), RGB(0, 0, 0));
int nResponse = dlg.DoModal();
PngwindowSever pngSeverDlg;
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
m_pMainWnd = &pngSeverDlg;
int nRes = pngSeverDlg.DoModal(); //Domodal后会直接退出
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
m_pMainWnd = &dlg;你将App类的m_pMainWnd关联了你的CPngWindowDlg,当你的这个主对话框窗口关闭的时候,主线程的消息循环就已经结束了,所以你后面创建的就一闪而过了。去掉m_pMainWnd = &dlg;即可