答:1)为什么你既建立线程又将一个类成员作为线程处理?这样的话谁来调用你的析构函数?你不能试图将文档视窗类中的成员作为线程,象这样:
Ccapi::SomeFunction() { AfxBeginThread(static_cast<whatever string of casts to make this link>(ThreadProc(this))); } Ccapi::ThreadProc(LPVOID ptr) { // ptr and this are equal... Ccapi* ptrApi = (Ccapi*)ptr; };</whatever>如果你是这样做的话可能需要做些改动
if (NULL == capi) ::MessageBox(NULL, "bad capi", "CapiThread", MB_OK); else if (NULL == capi->m_pOwner) ::MessageBox(NULL, "bad Owner", "CapiThread", MB_OK); else if (!::IsWindow(capi->m_pOwner->m_hWnd)) ::MessageBox(NULL, "bad hwnd", "CapiThread", MB_OK);