mfc - DoModal() 在第一行断言

标签 mfc visual-c++ modal-dialog

我在 Visual Studio 2008 中创建了一个基于 MFC 对话框的应用程序。

CCalendarWindowDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();

当我运行应用程序时,DoModal() 在第一行断言

INT_PTR CDialog::DoModal()
{
    // can be constructed with a resource template or InitModalIndirect
    ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
    m_lpDialogTemplate != NULL);
}

有人可以帮忙吗?

最佳答案

为了在我的 Dialog 类的构造函数中解决这个问题,我做了类似的事情

CCalendarWindowDlg::CCalendarWindowDlg ()
    :CDialog(IDD)
{
}

请注意,我正在使用我要呈现的表单的资源 ID 调用 CDialog 父类的构造函数。

关于mfc - DoModal() 在第一行断言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2040376/

相关文章:

iphone - PresentModalViewController 使我的应用程序崩溃

javascript - 在按钮单击事件上关闭模式对话框

javascript - 动态构建模态

c++ - MFC CPen::CreatePen 线宽

c++ - 预编译 header 选项会导致此错误吗?

c++ - 静态常量数组在 MSVC 中动态初始化?

c++ - 如何设置条形图的起点

visual-c++ - 如何在mfc中添加颜色选择器?

c++ - 从子对话框访问变量

c++ - 写入 COM 端口