/ Published in: C++

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
inline void ASSERT_GUI_THREAD() { const CWnd * pWnd = AfxGetMainWnd(); const HWND hWnd = pWnd->GetSafeHwnd(); const DWORD WindowThreadId = GetWindowThreadProcessId( hWnd, 0 ); const DWORD thisThreadId = AfxGetThread()->m_nThreadID; // const bool bGuiThread = IsGUIThread(FALSE); // ctrlTree.InvokeRequired == false // this might work in .NET but not MFC. bool isGuiThread = pWnd != NULL && hWnd != NULL && thisThreadId == WindowThreadId; ASSERT( isGuiThread ); }
Comments
