Recent

Author Topic: Cellhint in TDrawgrid  (Read 2157 times)

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Cellhint in TDrawgrid
« on: October 29, 2014, 10:36:02 am »
TStringGrid has the property OnGetCellHint to show a hintwindow with is requested note. TDrawgrid doesn't have this property. I tried to get a hint with a example on this page, but it hang up the application and only can be killed by brute force.

Why doesn't TDrawgrid that property and how another way to show a hint window?
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Cellhint in TDrawgrid
« Reply #1 on: October 29, 2014, 07:08:07 pm »
You can use the OnShowHint-Event.

Code: [Select]
<TDrawGrid>.OnShowHint:=@<TDrawGrid>.DoShowHint;

procedure <TDrawGrid>.DoShowHint(Sender: TObject; HintInfo: PHintInfo);
var
  ax,ay: byte;
begin
  if MouseToCell(HintInfo^.CursorPos.X,HintInfo^.CursorPos.Y,ax,ay) then
    HintInfo^.HintStr:='Hello World';
end;
Lazarus 1.7 (SVN) FPC 3.0.0

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: Cellhint in TDrawgrid
« Reply #2 on: October 30, 2014, 11:53:18 am »
Thanks. I had to change the procedure a little bit, because MouseTocell is a procedure and doesn't give a boolean back.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Cellhint in TDrawgrid
« Reply #3 on: October 30, 2014, 12:48:30 pm »
Yes, I just did copy/paste a procedure from my program where I override MouseToCell(). But the idea was clear, I guess.
Lazarus 1.7 (SVN) FPC 3.0.0

 

TinyPortal © 2005-2018