Zitat von
neolithos:
Nur mit ImageList_Draw habert es noch! Weis jemand was?
Setz die Hintergrundfarbe der ImageList auf die Farbe des ListView.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
IconCount: Integer;
IconIndex: Integer;
LargeIcon: HICON;
IconObject: TIcon;
ListItem: TListItem;
begin
ListView1.Clear();
ImageList1.Clear();
ImageList1.BkColor := ListView1.Color; // <- wichtig :)
IconCount := ExtractIconEx(shell32, -1, HICON(nil^), HICON(nil^), 0);
if IconCount > 0 then
begin
ImageList1.Width := GetSystemMetrics(SM_CXICON);
ImageList1.Height := GetSystemMetrics(SM_CYICON);
for IconIndex := 0 to IconCount - 1 do
begin
LargeIcon := 0;
if (ExtractIconEx(shell32, IconIndex, LargeIcon, HICON(nil^), 1) > 0) and
(LargeIcon <> 0) then
try
IconObject := TIcon.Create();
try
IconObject.Handle := LargeIcon;
ImageList1.AddIcon(IconObject);
ListItem := ListView1.Items.Add();
ListItem.Caption := '#' + IntToStr(IconIndex);
ListItem.ImageIndex := IconIndex;
finally
IconObject.Free();
end;
finally
DestroyIcon(LargeIcon);
end;
end;
end;
end;