CreateSolidBrush function (wingdi.h)

The CreateSolidBrush function creates a logical brush that has the specified solid color.

Syntax

HBRUSH CreateSolidBrush(
  [in] COLORREF color
);

Parameters

[in] color

The color of the brush. To create a COLORREF color value, use the RGB macro.

Return value

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

If the function fails, the return value is NULL.

Remarks

When you no longer need the HBRUSH object, call the DeleteObject function to delete it.

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

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

To paint with a system color brush, an application should use GetSysColorBrush (nIndex) instead of CreateSolidBrush(GetSysColor(nIndex)), because GetSysColorBrush returns a cached brush instead of allocating a new one.

ICM: No color management 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 Creating Colored Pens and 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

COLORREF

CreateDIBPatternBrush

CreateDIBPatternBrushPt

CreateHatchBrush

CreatePatternBrush

DeleteObject

GetSysColorBrush

RGB

SelectObject