windows_programming_notes.nbk: Home | Index | Next Page: SetDlgItemInt | Previous Page: SetCursorPos


 SetDCPenColor

SetDCPenColor function sets the current device context (DC) pen 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 SetDCPenColor(
      HDC hdc,          // handle to DC
      COLORREF crColor  // new pen color
    );

Parameters

Return Values

If the function succeeds, the return value specifies the previous DC pen color as a COLORREF value. If the function fails, the return value is CLR_INVALID.

Remarks

The function returns the previous DC_PEN color, even if the stock pen DC_PEN is not selected in the DC; however, this will not be used in drawing operations until the stock DC_PEN is selected in the DC.

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.

For an example of setting colors, see Setting the Pen or Brush Color.

Requirements


windows_programming_notes.nbk: Home | Index | Next Page: SetDlgItemInt | Previous Page: SetCursorPos


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time