Re: does my app need to intercept wm_quit?
It didn't work in this test I tried.
The message box "Thread running" pops up, but if I quit the app from
file/quit, the end of message box never appears. I also tried deriving
a class from CWinThread and overrode ExitInstance but ExitInstance
never gets called.
Any ideas? (Ps I'm sure this has been solved thousands of times before
but I don't know where to look)
UINT MyControllingFunction( LPVOID pParam ) {
MSG msg;
BOOL bRet;
boolean done=false;
Sleep(2000);
AfxMessageBox(L"thread running");
while (!done && (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) {
switch (msg.message) {
default:
break;
}
}
AfxMessageBox(L"endofthread");
return 0;
}
On Aug 14, 3:37 pm, "Scott McPhillips [MVP]" <org-dot-mvps-at-
scottmcp> wrote:
alexlwrote:
Hi,
if I have a mfc thread that spawns a com object, does my thread need
to intercept WM_QUIT in its message loop before passing it up the
chain, that is if I have clean up code that needs to execute before
shut down?
Thx
The CWinThread message loop takes care of WM_QUIT for you. It calls
ExitInstance, which is a good place for you to clean up thread objects.
--
Scott McPhillips [MVP VC++]