HBRUSH CreateHatchBrush(fnStyle, clrref) | |||||
int fnStyle; | /* hatch style of brush | */ | |||
COLORREF clrref; | /* color of brush, */ |
The CreateHatchBrush function creates a brush that has the specified hatched pattern and color. The brush can then be selected for any device.
fnStyle
Specifies one of the following hatch styles for the brush:
Value | Meaning |
HS_BDIAGONAL | 45-degree upward hatch (left to right) |
HS_CROSS | Horizontal and vertical crosshatch |
HS_DIAGCROSS | 45-degree crosshatch |
HS_FDIAGONAL | 45-degree downward hatch (left to right) |
HS_HORIZONTAL | Horizontal hatch |
HS_VERTICAL | Vertical hatch |
clrref
Specifies the foreground color of the brush (the color of the hatches).
The return value is the handle of the brush if the function is successful. Otherwise, it is NULL.
When an application has finished using the brush created by the CreateHatchBrush function, it should select the brush out of the device context and then delete it by using the DeleteObject function.
The following illustration shows how the various hatch brushes appear when used to fill a rectangle:
The following example creates a hatched brush with green diagonal hatch marks and uses that brush to fill a rectangle:
HBRUSH hbr, hbrOld;
hbr = CreateHatchBrush(HS_FDIAGONAL, RGB(0, 255, 0));
hbrOld = SelectObject(hdc, hbr);
Rectangle(hdc, 0, 0, 100, 100);
CreateBrushIndirect, CreateDIBPatternBrush, CreatePatternBrush, CreateSolidBrush, DeleteObject, SelectObject