다음을 통해 공유


CBrush::CreateHatchBrush

Initializes a brush with the specified hatched pattern and color.

BOOL CreateHatchBrush(
   int nIndex,
   COLORREF crColor 
);

Parameters

  • nIndex
    Specifies the hatch style of the brush. It can be any one of the following values:

    • HS_BDIAGONAL   Downward hatch (left to right) at 45 degrees

    • HS_CROSS   Horizontal and vertical crosshatch

    • HS_DIAGCROSS   Crosshatch at 45 degrees

    • HS_FDIAGONAL   Upward hatch (left to right) at 45 degrees

    • HS_HORIZONTAL   Horizontal hatch

    • HS_VERTICAL   Vertical hatch

  • crColor
    Specifies the foreground color of the brush as an RGB color (the color of the hatches). See COLORREF in the Windows SDK for more information.

Return Value

Nonzero if successful; otherwise 0.

Remarks

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

Example

CBrush brush;
brush.CreateHatchBrush(HS_BDIAGONAL, RGB(255, 0, 0));

CBrush* pOldBrush;
CPen* pOldPen;

pOldBrush = (CBrush*)pDC->SelectObject(&brush);
pOldPen = (CPen*)pDC->SelectStockObject(NULL_PEN);
pDC->Ellipse(CRect(50, 50, 250, 250));

pDC->SelectObject(pOldBrush);
pDC->SelectObject(pOldPen);

Requirements

Header: afxwin.h

See Also

Reference

CBrush Class

Hierarchy Chart

CBrush::CreateBrushIndirect

CBrush::CreateDIBPatternBrush

CBrush::CreatePatternBrush

CBrush::CreateSolidBrush

CGdiObject::CreateStockObject

CreateHatchBrush

Other Resources

CBrush Members