I'm looking for method, event, ... so when I hover over a cell with the mouse, the mousepointers changes depending on the value of that cell.
f.e;
When the cell is empty, the default pointervalue is used, when a cell contains a value, it changes to a handpoint.
I found nowhere some method activated by moving the mouse over a grid.
I added a simple prog in which 3 images are available to be showed in a drawgrind. Added is an array 'pdfyes' which indicates that the concerned pdf is available.
How can I change the mousepointer, so that if the pointer becomes an crHandpoint when we hover over the cells and that the concerned pdf can be loaded.
Loading a pdf is already functioning. The only thing I would change is the pointer. On empty cells the default-value and only on the cover where the pdf is available (pdfyes) a handpoint-pointer should be present when we hover over that cell, image.
unit test_shoot_01;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Grids, Types;
type
{ TForm1 }
TForm1 = class(TForm)
shootgrid: TDrawGrid;
procedure FormCreate(Sender: TObject);
procedure shootgridDrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
private
public
end;
var
Form1: TForm1;
coverlist : array of TPicture;
pdfyes : array of boolean;
cover_index : integer;
cover_index_nr : integer;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
setlength( coverlist, 3 );
setlength( pdfyes, 3 );
coverlist[ 0 ] := TPicture.Create;
coverlist[ 0 ].LoadFromFile('shoot01.jpg');
coverlist[ 1 ] := TPicture.Create;
coverlist[ 1 ].LoadFromFile('shoot02.jpg');
coverlist[ 2 ] := TPicture.Create;
coverlist[ 2 ].LoadFromFile('shoot03.jpg');
cover_index := length( coverlist );
pdfyes[ 0 ] := true;
pdfyes[ 1 ] := false;
pdfyes[ 2 ] := true;
end;
procedure TForm1.shootgridDrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
var
R : TRect;
ncel : integer;
TheGrid : TDrawGrid;
begin
TheGrid := Sender as TDrawGrid;
if cover_index > 0
then
begin
ncel := aCol + (aRow * TheGrid.ColCount) + 1;
//showmessage( inttostr( ncel - 1) + chr(10) + inttostr( cover_index) );
if ncel <= cover_index
then
begin
R := aRect;
R.Top := aRect.Top + 3;
R.Bottom := R.Top + coverlist[ ncel - 1 ].Height;
R.Left := aRect.Left + (aRect.Width - coverlist[ ncel - 1 ].Width) div 2;
R.Right := R.Left + coverlist[ ncel - 1 ].Width;
TheGrid.Canvas.StretchDraw( R, coverlist[ ncel - 1 ].Graphic );
end;
end;
end;
end.