非模态对话框的有关问题,这是咋回事
非模态对话框的问题,这是怎么回事?
各位大神,我在创建非模态对话框的时候,为什么第二次打开会出现错误。
void CWHView::OnDialog()
{
// TODO: Add your command handler code here
Dlg.Create(IDD_DIALOG1,this);
Dlg.ShowWindow(SW_SHOW);
}
CTestDlg Dlg; 定义成全局变量;
CWHView::~CWHView()
{
Dlg.DestroyWindow(); 析构函数销毁对话框
}
然后运行之后,第一次点开可以,但是第二次点开对话窗,就出现这个现象。
Debug Assertion Failed!
Program:D:\MFC\WH\Debug\WH.exe
File: wicore.cpp
Line: 639
For information on how your program can cause an assertin
failure,see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
但是我用new就不会出现这种情况。
CTestDlg *pDlg=new CTestDlg();
pDlg->Create(IDD_DIALOG1,this);
PDlg->ShowWindow(SW_SHOW);
------解决方案--------------------
各位大神,我在创建非模态对话框的时候,为什么第二次打开会出现错误。
void CWHView::OnDialog()
{
// TODO: Add your command handler code here
Dlg.Create(IDD_DIALOG1,this);
Dlg.ShowWindow(SW_SHOW);
}
CTestDlg Dlg; 定义成全局变量;
CWHView::~CWHView()
{
Dlg.DestroyWindow(); 析构函数销毁对话框
}
然后运行之后,第一次点开可以,但是第二次点开对话窗,就出现这个现象。
Debug Assertion Failed!
Program:D:\MFC\WH\Debug\WH.exe
File: wicore.cpp
Line: 639
For information on how your program can cause an assertin
failure,see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
但是我用new就不会出现这种情况。
CTestDlg *pDlg=new CTestDlg();
pDlg->Create(IDD_DIALOG1,this);
PDlg->ShowWindow(SW_SHOW);
------解决方案--------------------