CBrush::CreateBrushIndirect

初始化与 LOGBRUSH 结构指定的样式、颜色和模式的画笔。

BOOL CreateBrushIndirect(
   const LOGBRUSH* lpLogBrush 
);

参数

  • lpLogBrush
    指向 LOGBRUSH 包含有关画笔的信息的结构。

返回值

非零,如果函数运行成功;否则为0。

备注

画笔随后可以将选择作为当前画笔为所有设备上下文。

使用一个纯色(1结束平面,每像素1位)使用当前文本和背景色,位图创建的画笔绘制。 位表示的像素设置为0将绘制与当前文本颜色。 位表示的像素设置为1将绘制与当前背景色。

示例

// 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);

要求

Header: afxwin.h

请参见

参考

CBrush选件类

层次结构图

CBrush::CreateDIBPatternBrush

CBrush::CreatePatternBrush

CBrush::CreateSolidBrush

CBrush::CreateHatchBrush

CGdiObject::CreateStockObject

CGdiObject::DeleteObject

CreateBrushIndirect