Show different hints in TStringGrid cells at runtime
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 |
unit Unit2; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids; type TForm1 = class(TForm) StringGrid1: TStringGrid; . . . procedure FormCreate(Sender: TObject); private { Private declarations } public procedure HintHandler(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo); . . . end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.FormCreate(Sender: TObject); begin Application.OnShowHint := HintHandler; end; . . . procedure TForm1.HintHandler(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo); var Poin: TPoint; Col, Row: Integer; begin if HintInfo.HintControl <> StringGrid1 then Exit; Poin := StringGrid1.ScreenToClient(HintInfo.HintPos); StringGrid1.MouseToCell(Poin.X, Poin.Y, Col, Row); HintStr := Format('Hint for col %d and row %d', [Col, Row]); end; end. |