模态和非模态对话框 [英] Modal and modeless dialog

查看:86
本文介绍了模态和非模态对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在关闭无模式对话框时遇到问题.给出诸如调试断言失败"之类的错误.在dlgcore.cpp

我正在一个项目中,我正在从模式对话框中调用无模式对话框.
喜欢:

在模式对话框中,我正在调用无模式对话框
例如:

Hi,

i am facing a problem in closing the modeless dialog. giving some errors like "Debug Assertion Failed". in dlgcore.cpp

I am working on a project where i am calling a modeless dialog from the modal dialog.
Like:

in Modal dialog, i am calling a modeless dialog
ex:

a Class called CModalDlg.
void CModalDlg::OnCall()
{ 
   CDlg1* pDlg1 = new CDlg1;
   pDlg1->Create(CDlg1::IDD);
   pDlg1->ShowWindow(SW_SHOW);
}

in Modeless dialog, here i am trying to close the modeless dialog.
ex:
a class called CModelessDlg.
void CModelessDlg::OnCancel()
{
    CDialog::OnCancel();
}



我正在关闭像这样的无模式对话框,但是它给出了一个错误"Debug Assertion Failed".

我不知道我在哪里出问题.

谢谢您在Advance.



i am closing the modeless dialog like this but its giving an error "Debug Assertion Failed".

I dont know where i am making a problem.

Thank u in Advance.

推荐答案

不要为无模式对话框调用EndDialog()OnOK()OnCancel().这些功能仅用于模式对话框.从OnCancel()调用DestroyWindow().

您应该阅读有关无模式对话框的信息.例如此CP文章:教程-使用MFC的无模式对话框 [
Don''t call EndDialog(), OnOK() and OnCancel() for modeless dialogs. These functions are for modal dialogs only. Call DestroyWindow() from OnCancel().

You should read about modeless dialogs; e.g. this CP article: Tutorial - Modeless Dialogs with MFC[^].


这篇关于模态和非模态对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆