Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: xinyiman on October 13, 2010, 12:08:33 pm

Title: Color to cell grid! Problem in windows! (SOLVED)
Post by: xinyiman on October 13, 2010, 12:08:33 pm
procedure TForm1.Grid_RisultatoDrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect; aState: TGridDrawState);
var
   P : Array[0..200] Of Char;
begin
     If {(aCol = 1) And }(aRow = 0) Then
        begin
             Grid_Risultato.Canvas.Brush.Color := clGray;
             Grid_Risultato.Canvas.Pen.Color := clGray;
             Grid_Risultato.Canvas.Font.Color := clYellow;
             Grid_Risultato.Canvas.Rectangle(aRect.Left, aRect.Top, aRect.Right, aRect.Bottom);
        end;
end;

Why this works in Linux makes the cells in the first row of the grid with a gray background and yellow writing on Windows XP and does not display anything but a blank rectangle?
Title: Re: Color to cell grid! Problem in windows!
Post by: felipemdc on October 13, 2010, 02:41:09 pm
Did you try with the latest Lazarus 0.9.29?
Title: Re: Color to cell grid! Problem in windows!
Post by: xinyiman on October 13, 2010, 03:15:03 pm
My Lazarus info

Version #: 0.9.29
Data: 2010-10-01
Versione FPC: 2.4.3
Revisione SVN: 27534
i386-win32-win32/win64
Title: Re: Color to cell grid! Problem in windows!
Post by: bonmario on October 13, 2010, 05:37:16 pm
Try this:

Code: [Select]
procedure TForm1.Grid_RisultatoPrepareCanvas(sender: TObject; aCol, aRow: Integer;
  aState: TGridDrawState);
var
   P : Array[0..200] Of Char;
begin
     If {(aCol = 1) And }(aRow = 0) Then
        begin
             Grid_Risultato.Canvas.Brush.Color := clGray;
             Grid_Risultato.Canvas.Font.Color := clYellow;
        end;
end;

Hi, Mario
Title: Re: Color to cell grid! Problem in windows!
Post by: Ocye on October 13, 2010, 09:58:03 pm
Canvas.Brush.Style should be set to bsSolid. On Windows the default seems to be bsClear.
Title: Re: Color to cell grid! Problem in windows!
Post by: xinyiman on October 15, 2010, 01:38:52 pm
Neither solution worked!

Help me please!  :o
Title: Re: Color to cell grid! Problem in windows!
Post by: typo on October 15, 2010, 01:44:13 pm
It works for me.

Lazarus 0.9.29 r24105 FPC 2.4.0 i386-win32-win32/win64

Windows XP.
Title: Re: Color to cell grid! Problem in windows!
Post by: faber on October 15, 2010, 04:17:43 pm
I think it's a bug in grids. It works only with older rev.
Title: Re: Color to cell grid! Problem in windows!
Post by: faber on October 15, 2010, 04:24:56 pm
try in this way
Code: [Select]
     if (aRow = 0) Then begin
        StringGrid1.Canvas.Font.Color := clYellow;
        StringGrid1.Canvas.Brush.Color := clGray;
        StringGrid1.DefaultDrawCell(ACol,ARow, ARect, AState);
     end;
Title: Re: Color to cell grid! Problem in windows!
Post by: xinyiman on October 18, 2010, 06:53:56 am
try in this way
Code: [Select]
     if (aRow = 0) Then begin
        StringGrid1.Canvas.Font.Color := clYellow;
        StringGrid1.Canvas.Brush.Color := clGray;
        StringGrid1.DefaultDrawCell(ACol,ARow, ARect, AState);
     end;

Thank you. Is correct!  ;)
TinyPortal © 2005-2018