PRB: "Warning: Calling DestroyWindow in CWnd::~CWnd" MessageLast reviewed: May 28, 1997Article ID: Q105081 |
The information in this article applies to:
SYMPTOMSThe following warnings are displayed when a debug version of a program is executed and TRACE() diagnostics are enabled:
Warning: calling DestroyWindow in CWnd::~CWnd OnDestroy or PostNcDestroy in derived class will not be called CAUSEThe above warnings are displayed by the CWnd::~CWnd() destructor. The warnings indicate the following:
RESOLUTIONMFC Technote #17 contains more information on how to properly destroy a Window object and states the following cardinal rule:
To destroy a C++ Windows object, use DestroyWindow, not "delete".Also, examining CWnd::~CWnd() will reveal that the foremost task of the destructor is to ensure that the associated Windows window object has been destroyed. If a program calls DestroyWindow() before the CWnd destructor is called, the m_hWnd data member will be NULL, the TRACE0() messages will not occur, and DestroyWindow() will not be called in CWnd::~CWnd(). |
Keywords : MfcMisc kbfasttip kbprb
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |