Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
BOOLCreatePatternBrush(CBitmap*pBitmap);
Return Value
Nonzero if successful; otherwise 0.
Parameters
pBitmap
Identifies a bitmap.
Remarks
Initializes a brush with a pattern specified by a bitmap. The brush can subsequently be selected for any device context that supports raster operations. The bitmap identified by pBitmap is typically initialized by using the CBitmap::CreateBitmap, CBitmap::CreateBitmapIndirect, CBitmap::LoadBitmap, or CBitmap::CreateCompatibleBitmap function.
Bitmaps used as fill patterns should be 8 pixels by 8 pixels. If the bitmap is larger, Windows will only use the bits corresponding to the first 8 rows and columns of pixels in the upper-left corner of the bitmap.
A pattern brush can be deleted without affecting the associated bitmap. This means the bitmap can be used to create any number of pattern brushes.
A brush created using a monochrome bitmap (1 color plane, 1 bit per pixel) is drawn using the current text and background colors. Pixels represented by a bit set to 0 are drawn with the current text color. Pixels represented by a bit set to 1 are drawn with the current background color.
For information about using , a Windows function, see the Win32 SDK Programmer’s Reference.
Example
// Create a hatched bit pattern.
WORD HatchBits[8] = { 0x11, 0x22, 0x44, 0x88, 0x11,
0x22, 0x44, 0x88 };
// Use the bit pattern to create a bitmap.
CBitmap bm;
bm.CreateBitmap(8,8,1,1, HatchBits);
// Create a pattern brush from the bitmap.
CBrush brush;
brush.CreatePatternBrush(&bm);
// Select the brush into a device context, and draw.
CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush);
pDC->RoundRect(CRect(50, 50, 200, 200), CPoint(10,10));
// Restore the original brush.
pDC->SelectObject(pOldBrush);
CBrush Overview | Class Members | Hierarchy Chart
See Also CBitmap, CBrush::CreateBrushIndirect, CBrush::CreateDIBPatternBrush, CBrush::CreateHatchBrush, CBrush::CreateSolidBrush, CGdiObject::CreateStockObject