// TImagelist an XP anpassen, damit XP-Icons korrekt dargestellt werden.


// Getestet mit D4 unter XP
 


siehe Beispielaufruf

  

{$R XPSTYLE.res} // siehe Buttons im XP-Style anzeigen
 
uses commctrl; 
 
var 
  Mask: array[Boolean] of Integer = (0, ILC_MASK); 
 
procedure Convert(const IL: TImageList); 
var 
  hlp: TImageList; 
begin 
  if Assigned(IL) then 
  begin 
    hlp := TImageList.Create(nil); 
    hlp.Assign(IL); 
    with IL do 
      Handle := ImageList_Create(Width, Height, 
        ILC_COLOR32 or Mask[Masked], 0, AllocBy); 
    IL.AddImages(hlp); 
    hlp.free; 
  end; 
end; 
 
// Beispielaufruf 
 
procedure TForm1.Button2Click(Sender: TObject); 
var tli: TLIstitem; 
  datei: string; 
  FileInfo: SHFileInfo; 
begin 
  Listview1.LargeImages := IMagelist1; 
  Listview1.ViewStyle := vsIcon; 
  Datei := 'C:\info.txt'; 
  Imagelist1.Width := 32; 
  Imagelist1.Height := 32; 
  tli := Listview1.items.add; 
 
  tli.Caption := ExtractFileName(Datei); 
  SHGetFileInfo(pchar(Datei), 0, FileInfo, 
    sizeof(FileInfo), SHGFI_USEFILEATTRIBUTES or SHGFI_Icon); 
  tli.imageindex := ImageList_AddIcon(ImageList1.handle, FileInfo.HIcon); 
 
  Convert(Imagelist1); 
 
  tli := Listview1.items.add; 
  tli.Caption := Listview1.items[0].caption; 
  tli.imageindex := ImageList_AddIcon(ImageList1.handle, FileInfo.HIcon); 
end;



 

Zugriffe seit 6.9.2001 auf Delphi-Ecke