Reputation: 243
I have an MFC dialog based application created inside Visual Studio 2008.
CCalendarWindowDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
When I run the application, DoModal() asserts at very first line
INT_PTR CDialog::DoModal()
{
// can be constructed with a resource template or InitModalIndirect
ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
m_lpDialogTemplate != NULL);
}
Can anyone please help?
Upvotes: 3
Views: 3686
Reputation: 11
I had the same problem when just creating new dialog based MFC application using Visual Studio 2012. For me the solution was to use dialog construtor that takes dialog resource ID as parameter.
For instance:
CCalendarWindowDlg dlg(IDD_MYDIALOG);
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
Hope this helps.
Upvotes: 1
Reputation: 4335
For solving this in the Constructor of my Dialog class, I did something like
CCalendarWindowDlg::CCalendarWindowDlg ()
:CDialog(IDD)
{
}
Notice I am calling the constructor of the CDialog parent class with the resource ID of the form I want to present.
Upvotes: 3
Reputation:
Seems like the resource template is missing or wrongly mapped.
Look at the IDD attribute at your CCalendarWindowDlg class and see whether you have the appropriate dialog present in the Resource View.
Are you using the satellite DLLs for localization or other purpose? or the CCalendarWindowDlg component resource DLL might be missing.
Upvotes: 1