It is not a crash but an assertion is thrown. Assertions are only thrown in debug builds. They are mainly used to inform you during development that something weird has happened (read: the developer has made a serious mistake).
When mentioning a line number within an MFC source file like
wincore.cpp, you should also mention the used VS version or better open that file (it is located at
VC\atlmfc\src\mfc) and add the function name and the line content.
With my
wincore.cpp version the lines 412 to 414 are
CWnd* pWnd = CWnd::FromHandlePermanent(hWnd);
ASSERT(pWnd != NULL);
ASSERT(pWnd==NULL || pWnd->m_hWnd == hWnd);
with the
AfxWndProc()
function.
Run the program from the debugger and check the call stack when the assertion occurs to know for which window the function is called.
Read also about the
CPrintDialog Class[
^] and check if your code applies. Because you are creating the print dialog on the stack, it is deleted when going out of scope. Then an assertion for that window would occur earlier and not when closing the application. So the real reason for the assertion might be somewhere else in your application.
For better help you should post the complete function that uses the print dialog. Something like
void SomeClass::SomeFunc()
{
BOOL bPrintSetupOnly = FALSE;
CPrintDialog dlg(bPrintSetupOnly);
if (dlg.DoModal() == IDOK)
{
if (!bPrintSetupOnly) DeleteDC(dlg.m_pd.hDC);
}
}