DeleteObject Function

The DeleteObject function deletes a logical pen, brush, bitmap, font, or region from the system.

Syntax

BOOL DeleteObject(
      HGDIOBJ ho
    );
    

Parameters

ho

[in] A handle to the graphics device interface (GDI) object to be deleted.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Remarks

The handle passed to DeleteObject must be a local handle to a GDI object. For example, it must be created by a function such as CreatePen, CreateBrushIndirect, CreateBitmap, CreateFontIndirect, or CreatePolygonRgn. The handle must not be a handle to a shared GDI object, such as a device-dependent bitmap created by calling CreateCompatibleBitmap for a device context that is not the same as the one associated with the bitmap.

Note

You should call DeleteObject for every GDI object that you create. If you create a GDI object and do not delete it, your application will consume GDI resources. If your application creates too many GDI objects, it may crash.

Important

Do not call DeleteObject for objects selected into a device context. The system automatically deletes objects when they are no longer selected into a device context.

Requirements

Value
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

See also