What happen if delete a CWnd without calling CWnd::DestroyWindow()

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

After performing the following steps, what happen to my application or the
system:
1. My application has a class, namely CMyWnd, which is inherited from CWnd.
2. Instantiate a CMyWnd object by: CMyWnd* pMyWnd = new CMyWnd(...).
3. Call pMyWnd->CreateEx(...) to create the window.
4. (**DO NOT perform this step** Call pMyWnd->DestroyWindow() to destroy the
window.)
5. Release the CMyWnd object by: delete pMyWnd;

Please be note the destructor of CMyWnd does not called DestroyWindow() .
Here is declaration of the CMyWnd
class CMyWnd : public CWnd
{
CMyWnd()
{
}

~CMyWnd()
{
// do nothing
}
}
 
lauch2 said:
After performing the following steps, what happen to my application or the
system:
1. My application has a class, namely CMyWnd, which is inherited from CWnd.
2. Instantiate a CMyWnd object by: CMyWnd* pMyWnd = new CMyWnd(...).
3. Call pMyWnd->CreateEx(...) to create the window.
4. (**DO NOT perform this step** Call pMyWnd->DestroyWindow() to destroy the
window.)
5. Release the CMyWnd object by: delete pMyWnd;

Please be note the destructor of CMyWnd does not called DestroyWindow() .
Here is declaration of the CMyWnd
class CMyWnd : public CWnd
{
CMyWnd()
{
}

~CMyWnd()
{
// do nothing
}
}

CWnd::~CWnd does call DestroyWindow -- if it needs doing, and outputs a
debug warning that OnDestroy and PostNcDestroy will not be called.
 
Back
Top