Re: Using MFC dll from non-MFC application
"JRGlide" <JRGlide@discussions.microsoft.com> wrote in message
news:BB431F6F-5989-49F3-B99E-A204B81FAE94@microsoft.com...
There's a question about why doc/view would matter at all. But as
pointed out, a document
template is not needed because there is no app to open files, and the
others are
irrelevant.
The only reason I made it a doc/view was because the original program was.
After trying for while to make the doc/view work in a thread I dropped
that
idea and went to a WinFrame and child window. But now I'm having trouble
with even that.
For testing purposed I created a simple non-doc/view app from the wizard
and
converted it to a CWinThread. Here is how I call the thread from my hook
function:
void ViewPointCloud (void)
{
AFX_MANAGE_STATE (AfxGetStaticModuleState());
CViewPointCloudThread *pointCloudThread =
(CViewPointCloudThread*) AfxBeginThread
(RUNTIME_CLASS(CViewPointCloudThread));
WaitForSingleObject (pointCloudThread->m_hThread, INFINITE);
}
CViewPointClousThread is derived from CWinThread. The trouble I am having
is that I never come out of the WaitForSingleObject call after exiting the
GUI application.
When your main window is destroyed (PostNCDestroy) try calling
PostQuitMessage. That is how you make the thread quit.
The other strange thing is that the GUI doesn't even seem
to appear until after I call the WaitForSingleObject function.
No surprise there. Starting a thread does not instantly run the thread.
There is also a problem with waiting for m_hThread. The thread frees the
handle when it exits. To avoid that problem set the CWinThread's
m_bAutoDelete to FALSE.
--
Scott McPhillips [VC++ MVP]