Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Lazarus - How to make a hint for each listbox item

1 Posts
1 Users
0 Reactions
3,418 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2822
Topic starter  

Say you have a ListBox or for example a CheckListBox and you'd like to display a unique hint for each item ... how can we do this?

For this we use the OnMouseMove event of the ListBox. Make sure you've set Show to TRUE for the ListBox.

procedure TForm1.ListBox1MouseMove(Sender: TObject;  Shift: TShiftState; X, Y: Integer);
var ItemUnderMouse:integer;
begin
  ItemUnderMouse:=ListBox1.ItemAtPos(Point(X,Y),true);
  if (ItemUnderMouse>-1) and (ItemUnderMouse<ListBox1.Count) then
    begin
      // Create a unique hint for the item we're above
      ListBox1.Hint := 'A unique hint for '+ListBox1.Items[ItemUnderMouse];
    end
  else
    ListBox1.Hint:='This is a listbox and you are not hovering an item';
  Application.ActivateHint(ClientToScreen(Point(X,Y)));
end;                             

   
ReplyQuote
Share: