1,定义了全局对象 CEvent g_event(0,TRUE,0,0) //手动设置2,在主线程中:
m_pWinThread = AfxBeginThread(RUNTIME_CLASS(CSplashShow),THREAD_PRIORITY_NORMAL,0,0,NULL);
g_event.ResetEvent();
WaitForSingleObject(g_event.m_hObject,INFINITE);
m_pWinThread->PostThreadMessage(WM_QUIT,0,0);
3,在SplashShow.cpp 中:
CSplashWnd::SplashShow();
4,在SplashWnd.cpp 中:
SplashShow()
{
m_pSplashWnd = new CSplashWnd;
......
}
然后设置了一个定时器 m_nTimer=SetTimer(1,5000,NULL),在 OnTimer() 中
KillTimer(m_nTimer);
DestroyWindow();
g_event.SetEvent();;
CWnd::OnTimer(nIDEvent);
在 OnDestroy() 中
CWnd::OnDestroy();
delete this;
在程序运行中,内存出错。当把 OnDestroy() 删除,在程序退出时,内存泄露(也知道是 m_pSplashWnd 没有删除)请问,这个问题出在什么地方,应该如何修改。
m_pWinThread = AfxBeginThread(RUNTIME_CLASS(CSplashShow),THREAD_PRIORITY_NORMAL,0,0,NULL);
g_event.ResetEvent();
WaitForSingleObject(g_event.m_hObject,INFINITE);
m_pWinThread->PostThreadMessage(WM_QUIT,0,0);
3,在SplashShow.cpp 中:
CSplashWnd::SplashShow();
4,在SplashWnd.cpp 中:
SplashShow()
{
m_pSplashWnd = new CSplashWnd;
......
}
然后设置了一个定时器 m_nTimer=SetTimer(1,5000,NULL),在 OnTimer() 中
KillTimer(m_nTimer);
DestroyWindow();
g_event.SetEvent();;
CWnd::OnTimer(nIDEvent);
在 OnDestroy() 中
CWnd::OnDestroy();
delete this;
在程序运行中,内存出错。当把 OnDestroy() 删除,在程序退出时,内存泄露(也知道是 m_pSplashWnd 没有删除)请问,这个问题出在什么地方,应该如何修改。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货