The problem is:
a) ::CloseDesktop() insists upon no thread currently being assigned to the
desktop I am trying to close.
b) ::SetThreadDesktop() (which I need to call to resolve problem a.)
insists upon the desktop in which the thread currently is assigned to
having no attached windows and no hooks.
I have tried replacing hooking a virtual function (PostAfxEndThread()) into
a replacement for _AfxThreadEntry() in order to provide a "callback"
between the AfxEndThread() call and the _endthreadex() call, but something
still prevents the call to ::SetThreadDesktop() from succeeding. A few
breakpoints placed strategically seem to indicate that the MFC dll still
has some hooks into the thread which don't get cleaned up until the
_endthreadex() call.
Any ideas?
My best guess at the moment is a notification message from the thread to my
application's main thread, which is processed by waiting for the real
termination of the thread and then doing the cleanup from outside the
thread.
Thanks,
--Brent
PS. (Mike Blasczak are you listening? I think you would know...)
------------------------------------------------------------------------
S. Brent Faulkner
br...@golden.net (home)
br...@allross.com (business)