TPFGuru
2006-01-11 00:16:02 UTC
I created my MFC app as SDI without doc/view support. The
CMyWindowFrame::OnCreate function creates the status and tool bars, and
returns -1 if a failure occurs. So, I decided to put my code here to also
return -1 if my app fails to create a DirectX device.
I am messing around with the device creation and actually caused it to fail,
but when my app returns -1 in the OnCreate function, I get an exception in a
MFC program (winocc.cpp):
BOOL CWnd::ShowWindow(int nCmdShow)
{
ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
if (m_pCtrlSite == NULL)
return ::ShowWindow(m_hWnd, nCmdShow);
else
return m_pCtrlSite->ShowWindow(nCmdShow);
}
It bombs on the last instruction, because m_pCtrlSite is 0xfeeefeee.
Now I wonder what would happen if it failed to create the status bar or
toolbar. Did I find a bug in MFC (no one ever tested the failure to create
the other resources)?
I tried to add the AfxAbort() command, but it is not very graceful either.
How can I make the program exit in this situation?
Thanks.
CMyWindowFrame::OnCreate function creates the status and tool bars, and
returns -1 if a failure occurs. So, I decided to put my code here to also
return -1 if my app fails to create a DirectX device.
I am messing around with the device creation and actually caused it to fail,
but when my app returns -1 in the OnCreate function, I get an exception in a
MFC program (winocc.cpp):
BOOL CWnd::ShowWindow(int nCmdShow)
{
ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
if (m_pCtrlSite == NULL)
return ::ShowWindow(m_hWnd, nCmdShow);
else
return m_pCtrlSite->ShowWindow(nCmdShow);
}
It bombs on the last instruction, because m_pCtrlSite is 0xfeeefeee.
Now I wonder what would happen if it failed to create the status bar or
toolbar. Did I find a bug in MFC (no one ever tested the failure to create
the other resources)?
I tried to add the AfxAbort() command, but it is not very graceful either.
How can I make the program exit in this situation?
Thanks.