1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
const
BRUSH_COLORS : array[Boolean{Fixed}, Boolean{Selected}] of Color = (
(clWhite, clNavy),
(clSkyBlue, clSkyBlue)
);
TEXT_COLORS: array[Boolean{Selected}] of Color = (clBlue, clWhite);
COL_TEXT_COLORS: array[0..2{ACol}] of TColor = (clBlue, clRed, clGreen);
COL_TEXT_FONT_SIZES: array[0..2{ACol}] of Integer = (16, 14, 12);
begin
with (Sender As TStringGrid).Canvas do
begin
Brush.Color := BRUSH_COLORS[gdFixed in State, gdSelected in State];
FillRect(Rect);
SetTextColor(Handle, TEXT_COLORS[gdSelected In State]);
if ((ARow = 1) and (ACol = 0)) or ((ARow > 0) and (ACol in [1..2])) then
begin
Font.Size := COL_TEXT_FONT_SIZES[ACol];;
SetTextColor(Handle, COL_TEXT_COLORS[ACol]);
end
else
Font.Size := 8;
DrawText(Handle, PChar((Sender As TStringGrid).Cells[ACol, ARow]), -1, Rect ,
DT_CENTER or DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE );
end;
end; |
Partager