我试过用一个全局指针不行,调试通不过, 调试出现下列问题: ASSERT((p = pMap->LookupPermanent(m_hWnd)) != NULL || (p = pMap->LookupTemporary(m_hWnd)) != NULL); ASSERT((CWnd*)p == this); // must be us // Note: if either of the above asserts fire and you are // writing a multithreaded application, it is likely that // you have passed a C++ object from one thread to another // and have used that object in a way that was not intended. // (only simple inline wrapper functions should be used) // // In general, CWnd objects should be passed by HWND from // one thread to another. The receiving thread can wrap // the HWND with a CWnd object by using CWnd::FromHandle. // // It is dangerous to pass C++ objects from one thread to // another, unless the objects are designed to be used in // such a manner.不知道用mutex,或semaphore该怎么做
调试出现下列问题:
ASSERT((p = pMap->LookupPermanent(m_hWnd)) != NULL ||
(p = pMap->LookupTemporary(m_hWnd)) != NULL);
ASSERT((CWnd*)p == this); // must be us // Note: if either of the above asserts fire and you are
// writing a multithreaded application, it is likely that
// you have passed a C++ object from one thread to another
// and have used that object in a way that was not intended.
// (only simple inline wrapper functions should be used)
//
// In general, CWnd objects should be passed by HWND from
// one thread to another. The receiving thread can wrap
// the HWND with a CWnd object by using CWnd::FromHandle.
//
// It is dangerous to pass C++ objects from one thread to
// another, unless the objects are designed to be used in
// such a manner.不知道用mutex,或semaphore该怎么做
HWND hwnd=::FindWindow(NULL,"dialog's caption");
CDialog* pDialog=(CDialog*)CWnd::FromHandle(hwnd);
pDialog->MoveWindow(……);
在另外的线程中if (pMyDialog) { do }
&theadpart,
THREAD_PRIORITY_LOWEST);
中theadpart结构变量来传递对话框的句柄,这样能传过去,但通过FromHanle来得到该对话框的指针后,通过该指针来调用UpdateData(false), 调试不出错,但就是对话框里的数据没有被更新。