I bring up a window which stays up for 3 seconds, after which it automatically closes. The mechanism for this is that I have a worker thread which sends WM_CLOSE message to this window after 3 seconds and the thread ends as well having done its job.
The problem is that I need to bring window up again based on user action but there is no good way how can I tell if this window is already up or not.
The CStatusWnd has the thread function which sends it WM_CLOSECode:void CDemoDlg::ShowStatusWnd() { m_pWnd = new CStatusWnd; // create and display m_pWnd->Create(m_pMainFrame); m_hwndSafeWnd = m_pWnd->GetSafeHwnd(); }
The problem is I keep track of CStatusWnd with m_pWnd pointer but how do I know [in ShowStatusWnd() function] that I have window up or it contains lefover values? Is there a way I can set to NULL when window is destroyed?Code:UINT CStatusWnd::EndStatusWnd(LPVOID pParam) // thead function { CStatusWnd * wnd = (CStatusWnd *) pParam; Sleep(3000); ::PostMessage( wnd->m_hWnd, WM_CLOSE, 0, 0 ); }
Another question with this is should I be deleting the C++ object in PostNcDestroy() handler like below?
Code:void CStatusWnd::PostNcDestroy() { CWnd::PostNcDestroy(); delete this; }


Reply With Quote
