CTestDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
nResponse = dlg.DoModal();
nResponse = dlg.DoModal();
这样 怎么不行?
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
nResponse = dlg.DoModal();
nResponse = dlg.DoModal();
这样 怎么不行?
调试欢乐多
模式对话框只有关闭之后,DoModal才会返回
只有返回了才能往下执行你到底要实现什么样的需求呢
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
nResponse = dlg.DoModal();
nResponse = dlg.DoModal();
你代码写到InitInstance里了?
你要做个什么样的程序啊
=========
将这个去掉吧
{
...
...
#define MAX_COUNT 3 CAADlg dlg[MAX_COUNT];
m_pMainWnd = &dlg[MAX_COUNT-1]; for(int i=0; i<MAX_COUNT; i++)
{
dlg[i].Create(IDD_AA_DIALOG);
dlg[i].ShowWindow(SW_SHOW);
}
MSG msg;
while(::GetMessage(&msg, NULL, 0, 0))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
return FALSE;
}// 这样就改成非模态对话框了,但是你要自己处理对话框退出了,因为你在非模态对话框点击IDOK/IDCANCEL或者是点击对话框上的“X"关闭按钮只是隐藏了对话框,程序并没有退出!!你必须修改对话框的类,自己处理这些事件
class CAADlg : public CDialog
{
...
...
protected:
static int m_nCount;
static void ExitProc();
...
afx_msg void OnClose();
virtual void OnOK();
virtual void OnCancel();
};int CAADlg::m_nCount = 0;CAADlg::CAADlg(CWnd* pParent /*=NULL*/)
: CDialog(CAADlg::IDD, pParent)
{
....
++m_nCount;
}
void CAADlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
CDialog::OnClose(); ExitProc();
}void CAADlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK(); ExitProc();
}void CAADlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel(); ExitProc();
}void CAADlg::ExitProc()
{
m_nCount--;
if(0 == m_nCount)
{
PostQuitMessage(0);
}
}