CreateSolidBrush Function

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

Syntax

HBRUSH CreateSolidBrush(
  COLORREF color
);

Parameters

Parameter Description
color

The red, green, blue (RGB) color value for the brush. This parameter is a 32-bit value that specifies the intensity of red, green, and blue, respectively. The high byte is unused, the next byte contains red, the next byte contains green, and the low byte contains blue.

This parameter can be a standard color value, or a custom RGB value.

For example:

RGB(255, 0, 0) // Pure red
RGB(0, 255, 0) // Pure green
RGB(0, 0, 255) // Pure blue
RGB(255, 255, 255) // White
RGB(0, 0, 0) // Black

Return Value

If the function succeeds, the return value is a handle to the newly created logical brush.
If the function fails, the return value is NULL.

To get extended error information, call GetLastError.

Remarks

A logical brush is a graphics object used to paint the interior of polygons, rectangles, ellipses, and other closed shapes. It can also be used to draw lines and curves.

The CreateSolidBrush function creates a brush that uses a specified solid color. The color is defined by the color parameter, which is a 32-bit RGB value.

After you are finished with the brush, you must delete it by calling the DeleteObject function.

Requirements

Attribute Value
Minimum supported client Windows 2000 Professional
Minimum supported server Windows 2000 Server
Header wingdi.h (include Windows.h)
Library Gdi32.lib
DLL Gdi32.dll

See Also

Brushes, CreateBrushIndirect, DeleteObject, SelectObject, LOGBRUSH Structure