DeleteObject Function
Graphics Device Interface (GDI)
Syntax
BOOL DeleteObject(
[in] HGDIOBJ hObject
);
Parameters
hObject-
A handle to the graphics object to be deleted.
This handle must be obtained by calling a GDI function other than
GetStockObject.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
A deleted object can no longer be selected into any device context. The system frees the memory used by the object.
Do not delete stock objects obtained by calling GetStockObject.
Attempting to delete a stock object will cause an application error.
It is an error to delete an object that is currently selected into a device context. If you need to delete an object that is selected into a device context, you must first deselect it by selecting another object into the device context. For example, you can select a stock object such as the default palette or a NULL pen into the device context before deleting the object.
For applications that use GDI objects extensively, it is important to free all GDI objects that are no longer needed. An application can run out of system memory for GDI objects, which can cause GDI functions to fail.
Requirements
| Minimum supported client | Windows 2000 Professional [desktop apps only] |
| Minimum supported server | Windows 2000 Server [desktop apps only] |
| Header | wingdi.h (include Windows.h) |
| Library | Gdi32.lib |
| DLL | Gdi32.dll |