使用2个对话框窗口在MFC C ++中获取ASSERT错误 [英] Getting ASSERT error in MFC C++ using 2 dialog windows

查看:97
本文介绍了使用2个对话框窗口在MFC C ++中获取ASSERT错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我的应用程序中有2个模态对话框.从第一个按Enter(使用PreTranslateMessage)时,我通过DoModal()叫我第二个.
但是从第二个开始,当我按Escape键或单击"X"或按Alt + F4将其关闭时,它在行875的文件wincore.cpp中给我一个ASSERT错误.这是wincore的错误. .cpp文件:

Hello, i have 2 modal dialogs in my app. From the first one when i press ENTER(using PreTranslateMessage) i calls me the second one by DoModal().
But from the second, when i press Escape key, or click the ''X'', or press Alt+F4 to close it, it gives me an ASSERT error in file wincore.cpp on line 875. Here is the error from wincore.cpp file:

void CWnd::OnFinalRelease()
{
    if (m_hWnd != NULL)
        DestroyWindow();    // will call PostNcDestroy
    else                 // IT POINTS THIS LINE
        PostNcDestroy();
}



我只有Dialog1的DoModal,什么也没有.即使我不使用Dialog2(第二个对话框)中的任何代码.

我一直试图自己避免该错误,但我却无法避免.
在此先感谢您,我们将不胜感激!



I''m having just DoModal from Dialog1 and nothing else. Even i don''t use any pieces of code in Dialog2(the second dialog).

I''ve been trying to avoid that error myself but i wasn''t able to.
Thanks in advance, any help would be appreciated!

推荐答案

请在第一个对话框的OnEnter范围内发布
以及第二个对话框的类定义:)

您可以在没有失败的断言的情况下关闭第一个对话框吗?
Please post your OnEnter scope of the first dialog
and the class definition of the second dialog :)

Can you close yor first dialog without the failed assertions ?


让我猜想您的观点-

CDialog1-> EnterKey-> CDialog2////ri8正常吗?
可能是您同样针对Enter Key编写了代码-

CDialog2 Dlg2;
Dlg2.DoModal();

Dlg2成功显示(这就是所要的)

但是,如果您取消第二个对话框,则肯定会产生错误,因为它拥有第一个对话框的句柄.

尝试一次:

在第二个对话框中设置一个CloseDialog按钮,并为此编写代码
CDialog2 :: OnCloseDialog()
{
CDialog2 :: OnOK();
}

这将确保以我认为正确的方式终止第二个对话框
Let me guess ur points-

CDialog1->EnterKey->CDialog2 //This works fine ri8?
May be you have written the code against Enter Key likewise-

CDialog2 Dlg2;
Dlg2.DoModal();

And the Dlg2 appear successfully (That is what desired)

But from second dialog if you cancle this it will surely produce error, because, that holds the handle of First Dialog.

Try this once:

Set one CloseDialog Button in the Second Dialog and write code for that
CDialog2::OnCloseDialog()
{
CDialog2::OnOK();
}

This will ensure the termination of the Second dialog in proper way I guess


这篇关于使用2个对话框窗口在MFC C ++中获取ASSERT错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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