SetDCBrushColor

[This is preliminary documentation and subject to change.]

SetDCBrushColor function sets the current device context (DC) brush color to the specified color value. If the device cannot represent the specified color value, the color is set to the nearest physical color.

COLORREF SetDCBrushColor(
  HDC hdc,          // Handle to device context
  COLORREF crColor  // Specifies new brush color
);
 

Parameters

hdc
Handle to the device context.
crColor
Specifies the new brush color.

Return Values

If the function succeeds, the return value specifies the previous device context brush color as a COLORREF value.

If the function fails, the return value is CLR_INVALID.

Remarks

When the stock DC_BRUSH is selected in a device context, all the subsequent drawings will be done using the DC brush color until the stock brush is de-selected. The default DC_BRUSH color is WHITE.

The function will return the previous DC_BRUSH color, even if the stock brush DC_BRUSH is not selected in the DC: however, this will not be used in drawing operations until the stock DC_BRUSH is selected in the DC.

See Setting the Pen or Brush Color for an example of setting colors. The GetStockObject function with an argument of DC_BRUSH OR DC_PEN can be used interchangeably with the SetDCPenColor and SetDCBrushColor functions.

ICM: Color management is performed if ICM is enabled.

QuickInfo

  Windows NT: Requires version 5.0 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in wingdi.h.
  Import Library: Use gdi32.lib.

See Also

Device Contexts Overview, Device Context Functions, GetDCBrushColor.