Zitat von
marabu:
Hallo Peter,
schau mal:
Delphi-Quellcode:
procedure TDemoForm.ListViewClick(Sender: TObject);
var
item: TListItem;
pt: TPoint;
begin
with Sender as TListView do
begin
pt := ScreenToClient(Mouse.CursorPos);
item := GetItemAt(pt.X, pt.Y);
if Assigned(item)
then ShowMessage(item.Caption)
else ItemIndex := ItemFocused.Index;
end;
end;
Grüße vom marabu
Genial! Ich habe den Code nun erweitert:
Delphi-Quellcode:
procedure TForm1.ListViewClick(Sender: TObject);
var
item: TListItem;
pt: TPoint;
begin
with Sender as TListView do
begin
pt := ScreenToClient(Mouse.CursorPos);
item := GetItemAt(pt.X, pt.Y);
if (not Assigned(item)) and Assigned(ItemFocused) then
begin
ItemIndex := ItemFocused.Index;
end;
end;
if ListView.ItemIndex = -1 then
Windows.Beep(Random(100) + 150, 300);
end;