Why does my MFC program exit unexpectedly? The stack trace at the point we hit
ExitInstance
goes like this:CClientConsoleApp::ExitInstance CWinThread::Run+0x88 AfxWinMain+0x84 _wWinMainCRTStartup+0x138 BaseThreadInitThunk+0xe _RtlUserThreadStart+0x23Thanks.
You can already see some of what’s going on, but clearly more information is needed. My first psychic suggestion was to examine MFC’s message pump to see what causes it to exit. Then follow the money backwards.
That’s what we want to know and what we want to find out.
MFC comes with source code so you can do this yourself. Don’t expect somebody to do your debugging for you. You have the tools to do it yourself: You have the source code and you have a brain.
Once you figure out what conditions make MFC’s message pump exit, then try to figure out which of those conditions is actually occurring, and then set breakpoints to try to catch the condition being achieved.
I don’t have the MFC source code memorized and I didn’t feel like installing it just to help somebody solve their own problem, so I resorted to wild guessing in the guise of psychic powers:
I don’t know what MFC’s message pump looks like but my psychic powers tell me that it stops when it gets a
WM_QUIT
message. My psychic powers are losing strength from being so heavily stressed so early in the morning… I see a shadow, a vague form, it’s not all that clear, kind of hazy, it might be… yes I think it says “PostQuitMessage
“… hard to tell… connection fading…
(Sorry, I can’t finish up this story with a snappy ending. It happened so long ago I forget what the problem was.)
0 comments