Windows API Reference

GetStockObject

The GetStockObject function retrieves a handle to a specified stock pen, brush, font, or system color bitmap.

Syntax

HGDIOBJ GetStockObject(
  int fnObject
);

Parameters

fnObject [in]

The type of stock object to retrieve. This parameter can be one of the following values:

  • BLACK_BRUSH
  • DKGRAY_BRUSH
  • GRAY_BRUSH
  • HOLLOW_BRUSH
  • LTGRAY_BRUSH
  • NULL_BRUSH
  • WHITE_BRUSH
  • BLACK_PEN
  • INVERT_PEN
  • NULL_PEN
  • WHITE_PEN
  • ANSI_FIXED_FONT
  • ANSI_VAR_FONT
  • DEVICE_DEFAULT_FONT
  • Marlett
  • OEM_FIXED_FONT
  • SYSTEM_FONT
  • SYSTEM_FIXED_FONT
  • DEFAULT_PALETTE
  • GRAY_HALFTONE

Return Value

Return Value

If the function succeeds, the return value is a handle to the specified stock GDI object. If the function fails, the return value is NULL.

Remarks

Remarks

You do not need to release the handle obtained by calling GetStockObject. The system manages the memory associated with stock objects.

Do not attempt to delete a stock object using DeleteObject. Doing so will cause the system to behave unpredictably.

For a list of possible system colors, see SystemColor constants.

Requirements

Requirements

  • Minimum supported client: Windows 2000 Professional
  • Minimum supported server: Windows 2000 Server
  • Header: wingdi.h
  • Library: Gdi32.lib
  • DLL: Gdi32.dll