1. Computing

Display Long TListBox Delphi Items as Hints

From , former About.com Guide

Sometimes the data you want to display in a list is too long for the size of ListBox you can use. When this happens, you can use the simple code to display the ListBox entries as Hints when the mouse passes over the ListBox. Just make sure that ShowHints is True.

Drop a TLIstBox (name: ListBox1) on a Delphi form (name: Form1) and handle the OnMouseMove event as:

 procedure TForm1.ListBox1MouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer) ;
 var lstIndex : Integer ;
 begin
   with ListBox1 do
   begin
    lstIndex:=SendMessage(Handle, LB_ITEMFROMPOINT, 0, MakeLParam(x,y)) ;
    if (lstIndex >= 0) and (lstIndex <= Items.Count) then
      Hint := Items[lstIndex]
    else
      Hint := ''
    end;
   end;
 end.
 

Delphi tips navigator:
» Add a Check Box to a standard dialog box
« Copying group of files - standard animation dialog

©2013 About.com. All rights reserved.