16,551
社区成员
发帖
与我相关
我的任务
分享CBounceThread::CBounceThread()
{
}
CBounceThread::CBounceThread(HWND hwndParent) : m_hwndParent(hwndParent)
{
}
CBounceThread::~CBounceThread()
{
}
void CBounceThread::operator delete(void* p)
{
// The exiting main application thread waits for this event before completely
// terminating in order to avoid a false memory leak detection. See also
// CBounceWnd::OnNcDestroy in bounce.cpp.
SetEvent(m_hEventBounceThreadKilled);
CWinThread::operator delete(p);
}
int CBounceThread::InitInstance()
{
CWnd* pParent = CWnd::FromHandle(m_hwndParent);
CRect rect;
pParent->GetClientRect(&rect);
BOOL bReturn = m_wndBounce.Create(_T("BounceMTChildWnd"),
WS_CHILD | WS_VISIBLE, rect, pParent);
// It is important to set CWinThread::m_pMainWnd to the user interface
// window. This is required so that when the m_pMainWnd is destroyed,
// the CWinThread is also automatically destroyed. For insight into
// how the CWinThread is automatically destroyed when the m_pMainWnd
// window is destroyed, see the implementation of CWnd::OnNcDestroy
// in wincore.cpp of the MFC sources.
if (bReturn)
m_pMainWnd = &m_wndBounce;
return bReturn;
}