PRB: "Attempt to Delete Object Owned by System" ErrorLast reviewed: July 17, 1997Article ID: Q98200 |
1.00 1.50 1.51 1.52
WINDOWS
kbprg kbprb
The information in this article applies to:
The Microsoft Foundation Classes (MFC), included with: - Microsoft C/C++ version 7.0 - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, and 1.52
SYMPTOMSWhen an application passes the handle associated with a CBrush object to the AfxRegisterWndClass() function, an attempt to delete the CBrush object fails and Microsoft Windows generates the following message:
err MYAPP GDI: GDI: Attempt to delete object owned by system Fatal Exit Code = 0x8400 CAUSEThe AfxRegisterWndClass() function registers a window class. When an application registers a window class, the system takes ownership of any resources specified for the class. Windows deletes the objects when the application terminates or if the application calls the UnregisterClass() function to remove the class. The fatal error above occurs when the application attempts to delete the brush while it is owned by the system (in other words, while the window class is still registered). The destructor for the CBrush class calls DeleteObject() and causes this error.
RESOLUTIONThere are two methods to work around this situation, as follows:
STATUSThis behavior is by design.
MORE INFORMATIONThe following code demonstrates using the Detach() member function:
brush = new CBrush; // initialize brush // call AfxRegisterWndClass with brush brush->Detach(); delete brush;The "delete brush" statement deletes only the CBrush object; it does not destroy the actual Windows brush owned by the system. Windows destroys the brush when it deletes the window class.
|
Additional reference words: 1.00 1.50 1.51 1.52 2.51 2.52 Visual destructor
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |