unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TItemData =
class
private
fInfoString:
string;
public
property InfoString:
string read fInfoString;
constructor Create(aInfoString:
string);
end;
TForm1 =
class(TForm)
ListBox1: TListBox;
Button1: TButton;
lblItemData: TLabel;
procedure Button1Click(Sender: TObject);
procedure ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
{ Einfach mal ein paar sinnlose Einträge einfügen }
for i:= 0
to 10
do
ListBox1.Items.AddObject('
Eintrag Nr. ' + inttostr(i), TItemData.Create('
Daten zu Eintrag Nr. ' + inttostr(i)));
end;
{ TItemData }
constructor TItemData.Create(aInfoString:
string);
begin
inherited Create;
fInfoString:= aInfoString;
end;
procedure TForm1.ListBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
Index: integer;
begin
with TListbox(Sender)
do
begin
Index:= ItemAtPos(Point(x,y), true);
ShowHint:=
Index <> -1;
If (
Index <> -1)
then
Hint:= TItemData(Items.Objects[
Index]).InfoString;
end;
end;
end.