So sollte es gehen.
Addieren..
Delphi-Quellcode:
procedure TSkinListView.SetSysItemIcon(nItem, nSubItem: Integer; wsItems: WideString);
var
fi: TSHFileInfo;
begin
ZeroMemory(@fi, sizeof(TSHFileInfo));
if SHGetFileInfo(PWideChar(wsItems), 0, fi, sizeof(TSHFileInfo),
SHGFI_DISPLAYNAME Or SHGFI_SYSICONINDEX or SHGFI_SMALLICON or SHGFI_ICON) <> 0 then
begin
SetLength(ItemsInfo, nItem + 1);
ItemsInfo[nItem].Item := nItem;
ItemsInfo[nItem].SubItem := nSubItem;
ItemsInfo[nItem].Path := wsItems;
ItemsInfo[nItem].Extension := ExtractFileExt(wsItems);
// Extension geändert neues Icon addieren
if Extension <> ExtractFileExt(wsItems) then
begin
Extension := ItemsInfo[nItem].Extension;
ItemsInfo[nItem].ImgIcon := fi.hIcon;
Icon:= ItemsInfo[nItem].ImgIcon;
end
else
begin
// gleiche Extension fi.hIcon löschen
DestroyIcon(fi.hIcon);
ItemsInfo[nItem].ImgIcon := Icon;
end;
end;
end;
Freigeben
Delphi-Quellcode:
procedure TSkinListView.Clear(hListView: hWnd);
var
i: Integer;
count: Integer;
Icon: HICON;
begin
count := High(ItemsInfo);
Icon := 0;
for I := 0 to count - 1 do
begin
// Icon geändert dann löschen
if Icon <> ItemsInfo[i].ImgIcon then
begin
Icon := ItemsInfo[i].ImgIcon;
DestroyIcon(ItemsInfo[i].ImgIcon);
end;
end;
ListView_DeleteAllItems(hListView);
SetLength(ItemsInfo, 0);
end;
5700 Titel addiert ohne Probleme.
gruss