CreateSolidBrush

2.x

  HBRUSH CreateSolidBrush(clrref)    
  COLORREF clrref; /* brush color, */  

The CreateSolidBrush function creates a brush that has a specified solid color. The brush can subsequently be selected as the current brush for any device.

Parameters

clrref

Specifies the color of the brush.

Return Value

The return value is the handle of the brush if the function is successful. Otherwise, it is NULL.

Comments

When an application has finished using the brush created by CreateSolidBrush, it should select the brush out of the device context and then remove it by using the DeleteObject function.

Example

The following example uses the CreateSolidBrush function to create a green brush, selects the brush into a device context, and then uses the brush to fill a rectangle:

HBRUSH hbrOld;
HBRUSH hbr;

hbr = CreateSolidBrush(RGB(0, 255, 0));
hbrOld = SelectObject(hdc, hbr);
Rectangle(hdc, 10, 10, 100, 100);

See Also

CreateBrushIndirect, CreateDIBPatternBrush, CreateHatchBrush, CreatePatternBrush, DeleteObject