CreatePatternBrush function (wingdi.h)

The CreatePatternBrush function creates a logical brush with the specified bitmap pattern. The bitmap can be a DIB section bitmap, which is created by the CreateDIBSection function, or it can be a device-dependent bitmap.

Syntax

HBRUSH CreatePatternBrush(
  [in] HBITMAP hbm
);

Parameters

[in] hbm

A handle to the bitmap to be used to create the logical brush.

Return value

If the function succeeds, the return value identifies a logical brush.

If the function fails, the return value is NULL.

Remarks

A pattern brush is a bitmap that the system uses to paint the interiors of filled shapes.

After an application creates a brush by calling CreatePatternBrush, it can select that brush into any device context by calling the SelectObject function.

You can delete a pattern brush without affecting the associated bitmap by using the DeleteObject function. Therefore, you can then use this bitmap to create any number of pattern brushes.

A brush created by using a monochrome (1 bit per pixel) bitmap has the text and background colors of the device context to which it is drawn. Pixels represented by a 0 bit are drawn with the current text color; pixels represented by a 1 bit are drawn with the current background color.

ICM: No color is done at brush creation. However, color management is performed when the brush is selected into an ICM-enabled device context.

Examples

For an example, see Using Brushes.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wingdi.h (include Windows.h)
Library Gdi32.lib
DLL Gdi32.dll

See also

Brush Functions

Brushes Overview

CreateBitmap

CreateBitmapIndirect

CreateCompatibleBitmap

CreateDIBPatternBrush

CreateDIBPatternBrushPt

CreateDIBSection

CreateHatchBrush

DeleteObject

GetBrushOrgEx

LoadBitmap

SelectObject

SetBrushOrgEx