I had tried on draw but the code is never executed
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,unit2,
Grids;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; Col, Row: Integer; Rect: TRect; State: TGridDrawState);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
ended,deleted:boolean;
on_draw_cell_counter :integer;
implementation
{ TForm1 }
{**************************************************************}
procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col, Row: Integer;
Rect: TRect; State: TGridDrawState);
begin
on_draw_cell_counter:=on_draw_cell_counter+1;
If (gdFixed in State){or (gdSelected in State)} then exit;
if (Col = 2) and (Row = i) then begin
stringgrid1.canvas.Brush.Color:=clRed;
stringgrid1.canvas.FillRect(rect);
//stringgrid1.canvas.textRect(rect,Rect.left+2,rect.top+2,'ZZZZ'{stringgrid1.cells[Col,Row]});
StringGrid1.Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, 'ZZZZ');
end;
end;
{**************************************************************}
procedure load_form;
begin
Form1.StringGrid1.rowcount:=count;
p:=first^.next;
i:=0;
repeat
with p^ do
with form1.StringGrid1 do
begin
Cells[0,i]:= fName;
Cells[1,i]:= show_date(abs(time));
IF TIME<0 THEN Cells[2,i]:= 'To be deleted?' else Cells[2,i]:= '';
end;
i:=i+1;
p:=p^.next;
until p=last;
end;
{**************************************************************}
procedure TForm1.FormCreate(Sender: TObject);
begin
on_draw_cell_counter:=0; { to test count how often procedure TForm1.StringGrid1DrawCell is executed}
get_data;
load_form;
end;
{**************************************************************}
procedure TForm1.Button1Click(Sender: TObject); {end program}
var s:string;
begin
str(on_draw_cell_counter,s);
s:=s+' in on draw procedure';
ShowMessage (s); {to show how often procedure TForm1.StringGrid1DrawCell is executed}
close;
end;
{**************************************************************}
procedure TForm1.Button2Click(Sender: TObject); {delete files}
var s:string;
j:integer;
begin
delete_files(j);
end;
{**************************************************************}
initialization
{$I unit1.lrs}
end.
{**************************************************************}