在2个对话框之间切换-MFC [英] Switch between 2 dialogs - MFC

查看:47
本文介绍了在2个对话框之间切换-MFC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,但是即使我删除了关于第二个对话框的PreTranslateMessage(MSG * pMsg)函数,它仍然继续向我显示该错误:

调试断言失败:wincore.cpp行875

wincore.cpp中的代码说:

无效CWnd :: OnFinalRelease()
{
如果(m_hWnd!= NULL)
DestroyWindow(); //将调用PostNcDestroy
其他
PostNcDestroy();
}

Yeah, but even though i removed PreTranslateMessage(MSG* pMsg) function about the second dialog, it still continued showing me that error:

Debug Assertion Failed: wincore.cpp line 875

The code in wincore.cpp says:

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

推荐答案

我不明白为什么您在第二个对话框中摆弄PreTranslateMessage()的原因.退出键应激活第二个对话框的OnCancel(). CDialog中提供的一个应关闭对话框.



好吧,尽管不是问题,但还是消除了一项.我有几点想法/建议.我不知道有没有帮助.

1)一个没有任何控件的对话框绝对是奇怪的.我不知道你为什么要这样.我也不知道微软的代码将如何处理这种事情.尝试在对话框中添加一个可以接受焦点的控件(一个按钮即可),即使您没有执行任何操作.有区别吗?

2)您可以使用调试器并检查/确认哪个窗口/对话框正在触发断言吗?

3)您没有显示失败的实际断言.它是什么?它应该在源代码中的引用行上.

4)您如何处理关闭主(第一个)对话框?
I don''t see why you are fiddling with PreTranslateMessage() for your second dialog. The escape key should activate the OnCancel() of your second dialog. The one provided in CDialog should close the dialog.



Well, one item eliminated though it wasn''t the problem. I have several thoughts/suggestions. I don''t know if any will be helpful.

1) A dialog box without any controls on it is decidedly odd. I don''t know why you want such a thing. I also don''t know how microsoft''s code will or won''t deal with such a thing. Try adding a control that can accept focus ( a push button will do) to your dialog even though you don''t have it doing anything. Does it make a difference?

2) Can you use the debugger & check/confirm which window/dialog is triggering the assertion?

3) You are not showing the actual assertion that failed. What is it? It should be on the referenced line in the source code.

4) How are you handling closing your main (first) dialog?


这篇关于在2个对话框之间切换-MFC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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