Recent

Author Topic: Displying tooltips for each item in a TListView  (Read 403 times)

maurobio

  • Hero Member
  • *****
  • Posts: 638
  • Ecology is everything.
    • GitHub
Displying tooltips for each item in a TListView
« on: March 26, 2025, 12:55:41 pm »
Dear ALL,

Long time no see! But here am I back with a single question: how to get tooltips in a TListView component using Lazarus? I would like to display some details when the user moves the mouse over each item.

I found a few examples for Delphi, but they are all Windows-specific (of course).

Can any one out there give me some help?

Thanks in advance!
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 3.6 - FPC 3.2.2 on GNU/Linux Mint 19.1/20.1, Windows XP SP3, Windows 7 Professional, Windows 10 Home

Zvoni

  • Hero Member
  • *****
  • Posts: 2961
Re: Displying tooltips for each item in a TListView
« Reply #1 on: March 26, 2025, 01:09:39 pm »
Does it have to be a TListView?
Or is it actually a "misused" Grid (ListView in Report-Style)?

TStringGrid has CellHints....
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

maurobio

  • Hero Member
  • *****
  • Posts: 638
  • Ecology is everything.
    • GitHub
Re: Displying tooltips for each item in a TListView
« Reply #2 on: March 26, 2025, 01:12:32 pm »
Hi, Zvoni!

Yes, it should be a TListView (even if it is, as you say, a "misused" Grid in vsReport style).

Regards,
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 3.6 - FPC 3.2.2 on GNU/Linux Mint 19.1/20.1, Windows XP SP3, Windows 7 Professional, Windows 10 Home

Zvoni

  • Hero Member
  • *****
  • Posts: 2961
Re: Displying tooltips for each item in a TListView
« Reply #3 on: March 26, 2025, 01:21:49 pm »
In that case the only thing coming to mind, would be to use the ListView's own Hint/ShowHint, but with a "custom" OnShowHint-Handler.
Inside there you'd need to "calculate" over which cell you are hovering, the content, WHERE to show the Hint, whatever else.....

The "DeLuxe"-Solution would be to implement on your own....
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

maurobio

  • Hero Member
  • *****
  • Posts: 638
  • Ecology is everything.
    • GitHub
Re: Displying tooltips for each item in a TListView
« Reply #4 on: March 26, 2025, 01:31:37 pm »
Hi, Zvoni!

As matter of fact, I just managed to get it implemented and working fine, for a single and three-column TListView. I attach my sample code for perusal.

Regards,
UCSD Pascal / Burroughs 6700 / Master Control Program
Delphi 7.0 Personal Edition
Lazarus 3.6 - FPC 3.2.2 on GNU/Linux Mint 19.1/20.1, Windows XP SP3, Windows 7 Professional, Windows 10 Home

Zvoni

  • Hero Member
  • *****
  • Posts: 2961
Re: Displying tooltips for each item in a TListView
« Reply #5 on: March 26, 2025, 03:10:51 pm »
Hi, Zvoni!

As matter of fact, I just managed to get it implemented and working fine, for a single and three-column TListView. I attach my sample code for perusal.

Regards,
Nice. Looks simple enough....
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018