GetStockObject

  HGDIOBJ GetStockObject(fnObject)    
  int fnObject; /* type of stock object */

The GetStockObject function retrieves a handle to one of the predefined stock pens, brushes, fonts, or palette.

Parameters

fnObject

Specifies the type of stock object desired. It can be any one of the following values:

Value Meaning

BLACK_BRUSH Black brush
DKGRAY_BRUSH Dark gray brush
GRAY_BRUSH Gray brush
HOLLOW_BRUSH Hollow brush
LTGRAY_BRUSH Light gray brush
NULL_BRUSH Null brush
WHITE_BRUSH White brush
BLACK_PEN Black pen
NULL_PEN Null pen
WHITE_PEN White pen
ANSI_FIXED_FONT Windows fixed-pitch system font
ANSI_VAR_FONT Windows variable-pitch system font
DEVICE_DEFAULT_FONT Device-dependent font
OEM_FIXED_FONT OEM-dependent fixed font
SYSTEM_FONT System font. By default, Windows uses the system font to draw menus, dialog box controls, and other text. In Windows versions 3.0 and later, the system font is a variable-pitch font width; earlier versions of Windows use a fixed-pitch system font.
SYSTEM_FIXED_FONT Fixed-pitch system font used in Windows versions earlier than 3.0. This object is available for compatibility with earlier versions of Windows.
DEFAULT_PALETTE Default color palette. This palette consists of the static colors in the system palette.

Return Value

The return value is the handle of the desired logical object if the function is successful. Otherwise, it is NULL.

Comments

The DKGRAY_BRUSH, GRAY_BRUSH, and LTGRAY_BRUSH objects should be used only in windows with the CS_HREDRAW and CS_VREDRAW styles. Using a gray stock brush in any other style of window can lead to misalignment of brush patterns after a window is moved or sized. The origins of stock brushes cannot be adjusted.

The HOLLOW_BRUSH and the NULL_BRUSH are equivalent.