bigsteve87
asked on
Will deleting a CWnd through it's own PostNcDestroy message cause a memory leak if it was allocated on the heap?
I have a splash screen window that is allocated on the heap and deleted in it's PostNcDestroy message handler. Will this cause a memory leak?
The reason I'm asking is because a memory leak detection program pointed to the spot where I create a new Window on the heap with out deleting it before the function ended. It may be wrong in this case.
Details below, if needed:
It is created like this:
BOOL CMainFrame::ShowSplashScre en()
{
pSplash=new CSplashScreen();
pSplash->Create(this,_T("M y Splash"),1700,CSS_FADE | CSS_CENTERSCREEN | CSS_SHADOW);
pSplash->Show();
}
And deleted like this:
void CSplashScreen::PostNcDestr oy()
{
CWnd::PostNcDestroy();
delete this;
}
This is preferable because the splash screen is killed as soon as a timer runs out:
void CSplashScreen::OnTimer(UIN T nIDEvent)
{
KillTimer(0);
ShowWindow(SW_HIDE);
DestroyWindow();
}
The reason I'm asking is because a memory leak detection program pointed to the spot where I create a new Window on the heap with out deleting it before the function ended. It may be wrong in this case.
Details below, if needed:
It is created like this:
BOOL CMainFrame::ShowSplashScre
{
pSplash=new CSplashScreen();
pSplash->Create(this,_T("M
pSplash->Show();
}
And deleted like this:
void CSplashScreen::PostNcDestr
{
CWnd::PostNcDestroy();
delete this;
}
This is preferable because the splash screen is killed as soon as a timer runs out:
void CSplashScreen::OnTimer(UIN
{
KillTimer(0);
ShowWindow(SW_HIDE);
DestroyWindow();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER