471,114 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,114 software developers and data experts.

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 3713
"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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.