Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FillRect doesn't paint the complete TStringGrid cell in Delphi XE2

FillRect doesn't paint the complete TStringGrid cell in Delphi XE2. There is a gap of 3 pixels on the left side in the default color (with BiDiMode set to bdLeftToRight). This problem doesn't exist in Delphi 6 which I used before.

procedure TShapeline.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  Stringgrid1.Canvas.Brush.Color:=$00FF80FF;
  StringGrid1.Canvas.FillRect(Rect);
end;

I tried to change all properties (including the DrawingStyle) and different brush styles, the painted rectangle doesn't fill the complete cell.

like image 486
Finike Avatar asked Jan 10 '12 15:01

Finike


1 Answers

This is expected behaviour in XE2 when DefaultDrawing = true and themes are enabled (I'm not going to argue about good or bad here - as you might have noticed, the behaviour is different for RigthToLeft mode...).

A workaround is to check for this condition and decrement Rect.Left by 4 pixel before calling FillRect.

like image 159
Uwe Raabe Avatar answered Sep 21 '22 06:09

Uwe Raabe