The color of the hatched brush is the foreground color - the color of the hatch itself.
The background color is set separately when using shaded brushes and, as far as I know, is not displayed as a TCanvas property and therefore requires the use of the Windows GDI API SetBkColor ().
eg. to draw a red stroke on a white background, add a call to set the background color before drawing with the canvas brush:
image1.Canvas.brush.Style := bsDiagCross; image1.canvas.brush.color := clRed; SetBkColor(image1.Canvas.Handle, ColorToRGB(clWhite)); image1.canvas.FillRect(image1.clientrect);
[Update:] NOTE. . It looks like in Delphi 2010 (and possibly in some earlier versions) you should call SetBKColor () AFTER setting the brush properties. Internally, when the canvas creates it with a brush, it calls SetBKColor (), which tramples on any explicit calls to SetBKColor () made before the Canvas.Brush reference . The timing for creating an internal canvas brush or internal use of SetBkColor () seems to have changed between Delphi 2006 (used when testing the original publication) and Delphi 2010. Regardless of the reason, it is clearly more reliable to call SetBKColor immediately before using it.
source share