CBrush::CreateSysColorBrush

Initializes a brush color.

BOOL CreateSysColorBrush(
   int nIndex 
);

Parameters

  • nIndex
    Specifies a color index. This value corresponds to the color used to paint one of the 21 window elements. See GetSysColor in the Windows SDK for a list of values.

Return Value

Nonzero if successful; otherwise 0.

Remarks

The brush can subsequently be selected as the current brush for any device context.

When an application has finished using the brush created by CreateSysColorBrush, it should select the brush out of the device context.

Example

// Declare a CBrush and initialize to a system color.
CBrush brush;
brush.CreateSysColorBrush(COLOR_BTNFACE);

// Select the brush into the device context. 
CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush);

// Draw.
CRect rect(50, 50, 150, 150);
pDC->Rectangle(rect);

// Reselect the original brush.
pDC->SelectObject(pOldBrush);

Requirements

Header: afxwin.h

See Also

Concepts

CBrush Class

CBrush Members

Hierarchy Chart

CBrush::CreateBrushIndirect

CBrush::CreateDIBPatternBrush

CBrush::CreateHatchBrush

CBrush::CreatePatternBrush

CreateSolidBrush

CBrush::CreateSolidBrush

GetSysColorBrush

CGdiObject::DeleteObject