468,771 Members | 1,503 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

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

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
}
}
Nov 17 '05 #1
1 3549
"lauch2" <la****@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
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.
--
Jeff Partch [VC++ MVP]
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Joseph | last post: by
2 posts views Thread by Cantankerous Old Git | last post: by
1 post views Thread by Rajko | last post: by
1 post views Thread by Berrywong | last post: by
3 posts views Thread by blackbolek | last post: by
reply views Thread by Sudha | last post: by
4 posts views Thread by Mullai | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.