//声明: CreateBrushIndirect( const p1: TLogBrush {画刷结构} ): HBRUSH; {返回画刷句柄} //TLogBrush 是 tagLOGBRUSH 结构的重定义: tagLOGBRUSH = packed record lbStyle: UINT; {画刷风格} lbColor: COLORREF; {颜色} lbHatch: Longint; {阴影样式} end; //lbStyle 可选值: BS_SOLID = 0; BS_NULL = 1; BS_HOLLOW = BS_NULL; BS_HATCHED = 2; BS_PATTERN = 3; BS_INDEXED = 4; BS_DIBPATTERN = 5; BS_DIBPATTERNPT = 6; BS_PATTERN8X8 = 7; BS_DIBPATTERN8X8 = 8; BS_MONOPATTERN = 9; //lbHatch 可选值: HS_HORIZONTAL = 0; HS_VERTICAL = 1; HS_FDIAGONAL = 2; HS_BDIAGONAL = 3; HS_CROSS = 4; HS_DIAGCROSS = 5;
//举例: procedure TForm1.FormPaint(Sender: TObject); var b: TLogBrush; BrushHandle: HBRUSH; begin b.lbStyle := BS_HATCHED; b.lbColor := clRed; b.lbHatch := HS_CROSS; BrushHandle := CreateBrushIndirect(b); Canvas.Brush.Handle := BrushHandle; FillRect(Canvas.Handle, ClientRect, BrushHandle); DeleteObject(BrushHandle); end;
//效果图: