Share via


CBrush::CreateBrushIndirect

BOOLCreateBrushIndirect( const LOGBRUSH*lpLogBrush);

Return Value

Nonzero if the function is successful; otherwise 0.

Parameters

lpLogBrush

Points to a structure that contains information about the brush.

Remarks

Initializes a brush with a style, color, and pattern specified in a structure. The brush can subsequently be selected as the current brush for any device context.

A brush created using a monochrome (1 plane, 1 bit per pixel) bitmap is drawn using the current text and background colors. Pixels represented by a bit set to 0 will be drawn with the current text color. Pixels represented by a bit set to 1 will be drawn with the current background color.

Example

// Initialize a LOGBRUSH structure.
LOGBRUSH logBrush;
logBrush.lbStyle = BS_HATCHED;
logBrush.lbColor = RGB(0, 192, 192);
logBrush.lbHatch = HS_CROSS;

// Declare an uninitialized CBrush ...
CBrush brush;
// ... and initialize it with the LOGBRUSH.
brush.CreateBrushIndirect(&logBrush);

// Select the brush (and perhaps a pen) into
// the device context.
CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush);
CPen* pOldPen = (CPen*)pDC->SelectStockObject(BLACK_PEN);

// Have fun!
pDC->Pie(CRect(100, 100, 300, 300), CPoint(0, 0), CPoint(50, 200));

// Restore the original device context objects.
pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);

CBrush OverviewClass MembersHierarchy Chart

See Also   CBrush::CreateDIBPatternBrush, CBrush::CreatePatternBrush, CBrush::CreateSolidBrush, CBrush::CreateHatchBrush, CGdiObject::CreateStockObject, CGdiObject::DeleteObject,