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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids,
LCLintf, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
laDblClick : TLabel;
laClick : TLabel;
StringGrid1 : TStringGrid;
procedure FormCreate(Sender : TObject);
procedure StringGrid1Click(Sender : TObject);
procedure StringGrid1DblClick(Sender : TObject);
procedure StringGrid1MouseDown(Sender : TObject; Button : TMouseButton;
Shift : TShiftState; X, Y : Integer);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1 : TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.StringGrid1Click(Sender : TObject);
begin
laClick.caption := 'Click';
end;
procedure TForm1.FormCreate(Sender : TObject);
begin
laClick.caption := '';
laDblClick.caption := '';
end;
procedure TForm1.StringGrid1DblClick(Sender : TObject);
begin
laDblClick.caption := 'DblClick';
end;
procedure TForm1.StringGrid1MouseDown(Sender : TObject; Button : TMouseButton;
Shift : TShiftState; X, Y : Integer);
var
P : TPoint;
Rect : TRect;
begin
laClick.caption := '';
laDblClick.caption := '';
with StringGrid1 do begin
Rect.TopLeft := CellRect(FixedCols,FixedRows).TopLeft;
Rect.BottomRight := CellRect(ColCount -1, Rowcount -1).BottomRight;
P.X := X;
P.Y := Y;
end;
if not PtInRect(Rect, P) then Abort;
end;
end. |
Partager