Re: How to get crash dump when a unhandled CException is thrown by
a MFC app
Peter Schneider wrote:
On 11 Jan., 14:42, "Martin B." <0xCDCDC...@gmx.at> wrote:
Check the docs for:
virtual LRESULT ProcessWndProcException(CException* e, const MSG* pMsg);
If you add a THROW_LAST() in you own, you should be able to produce a
crash. (Except I think for the Modal Dialog Loop which contains an
additional CATCH that is not handled via ProcessWndProcException
Thanks for the suggestion! I will give it a try. (Unfortunately, our
app currently uses a modal dialog ...)
Where did you find the documenation on this?
I used the following MSDN link and it doesn't seem to contain anything
on it: http://msdn.microsoft.com/en-us/library/93k07whb.aspx
Peter
I can't remember exactly.
Probably it was "just" debugging through the MFC sourcecode (maybe
assisted by some google'd stuff).
Check out:
Microsoft Visual Studio 8\VC\atlmfc\src\mfc\dlgcore.cpp
and search for CATCH_ALL for the DoModal problem
Regarding the ProcessWndProc, here's how we do it:
class CMyApp : public CMyWinExcApp ...
// Common base app class:
class CMyWinExcApp : public CWinApp {
public:
DECLARE_DYNAMIC(CMyWinExcApp)
protected:
virtual LRESULT ProcessWndProcException(CException* e, const MSG* pMsg);
};
IMPLEMENT_DYNAMIC(CMyWinExcApp, CWinApp)
LRESULT CMyWinExcApp::ProcessWndProcException(CException* e, const MSG*
pMsg)
{
ASSERT(!"Unhandled CException caught!");
TCHAR buf[1024] = {0};
CString className;
if(e) {
e->GetErrorMessage(buf, 1024);
CRuntimeClass* pClass = e->GetRuntimeClass();
if(pClass && pClass->m_lpszClassName)
className = pClass->m_lpszClassName;
}
CString msg;
msg.Format(_T("Unhandled MFC Exception - %s: %s"), className, buf);
// ... Log or display msg ...
THROW_LAST();
}
br,
Martin