//聲明:
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;
//效果圖: