Navigate to the events tab of your DBGrid
and double-click OnMouseMove
. Delphi will automatically create the event, you will check the X
coordinate that would be the horizontal so it would be the column, so you should know what column would be the links in the emails, and if for example it was the column 3
it would check if it was empty and would set the Cursor, see how it would work:
You first have to declare Type
to access private properties:
type
THackGrid = class(TCustomDBGrid); //criar uma nova classe pra acessar as propriedades privadas
And here is the function of MouseMove
:
procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
pt: TGridcoord;
MouseScrPt : TPoint;
OrigActiveRecord : integer;
begin
pt:= DBGrid1.MouseCoord(x, y);
if dgTitles in DBGrid1.Options then Dec(pt.y); //se o titulo é mostrado então ajusta a row index(-1) para nao dar erro de argument out of range
if dgIndicator in DBGrid1.Options then Dec(pt.x); //se o indicador é mostrado então ajusta a column index (-1) para nao dar erro de argument out of range
if THackGrid(DBGrid1).DataLink.Active and (pt.y>=0) and (pt.x>=3) then
begin
THackGrid(DBGrid1).DataLink.ActiveRecord:= pt.y;
if (DBGrid1.Columns[pt.x].Field.AsString <> '') and (pt.x=3) then
DBGrid1.Cursor:=crHandPoint
else
DBGrid1.Cursor:=crDefault;
end;
end;