Author: Tomas Rutkauskas
How can I make a hint for a single cell in a TDBGrid or TDrawGrid? I want to
display any text in a grid cell even if it is not placed in the cell completely.
Answer:
Here's an example taken from a working app but simplified a little. OldHintRow and
OldHintCol are private variables declared in TStosWin. They store the column and
row for which the hint was shown previously.
1 2 procedure TStosWin.MyDrawGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y:
3 Integer);
4 var5 R, C: Integer;
6 begin7 with MyDrawGrid1 do8 begin9 MouseToCell(X, Y, C, R);
10 if (C = OldHintCol) and (R = OldHintRow) then11 exit; {Don't do anything if mouse is in the same cell}12 OldHintCol := C;
13 OldHintRow := R;
14 Hint := ' Your hint for column C and row R';
15 {Force the hint to redisplay}16 PostMessage(Handle, WM_MBUTTONDOWN, MK_LBUTTON, Dword((Y shl 16) + X));
17 end;
18 end;