How to create a brush using CreateBrushIndirect (Views: 28)
Problem/Question/Abstract: How to create a brush using CreateBrushIndirect Answer: procedure TForm1.Button1Click(Sender: TObject); var Region: HRGN; LogBrush: TLogBrush; NewBrush: hBrush; begin with LogBrush do begin lbStyle := BS_HATCHED; lbColor := clBlue; lbHatch := HS_CROSS end; NewBrush := CreateBrushIndirect(LogBrush); Region := CreateEllipticRgnIndirect(PaintBox1.BoundsRect); FillRgn(PaintBox1.Canvas.Handle, Region, NewBrush); DeleteObject(NewBrush); DeleteObject(Region) end; |