Thema: Delphi Icons pixelig...

Einzelnen Beitrag anzeigen

delphinia

Registriert seit: 16. Feb 2006
444 Beiträge
 
Delphi 11 Alexandria
 
#6

Re: Icons pixelig...

  Alt 16. Mär 2006, 10:03
Nun habe ich den Code für die schwarzen Ränder in die OnCreate gepackt - nun sind meine Icons aber in Mini-Format

meine QuellCode:


Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
  LV_InsertFiles_1('C:\Windows\System32\', JvListView1, ImgLst);
end;

Delphi-Quellcode:
procedure LV_InsertFiles_1(strPath: string; ListView: TlistView; ImageList: TJvImageList);
var
  i: Integer;
  Icon: TIcon;
  SearchRec: TSearchRec;
    ListItem: TListItem;
  FileInfo: SHFILEINFO;
begin
  Icon := TIcon.Create;
  ListView.Items.BeginUpdate;

  try
    i := FindFirst(strPath + '*.exe', faAnyFile, SearchRec);
    while i = 0 do
    begin
      with ListView do
      begin
        if ((SearchRec.Attr and FaDirectory <> FaDirectory) and
          (SearchRec.Attr and FaVolumeId <> FaVolumeID)) then
        begin
          ListItem := ListView.Items.Add;

          SHGetFileInfo(PChar(strPath + SearchRec.Name), 0, FileInfo, SizeOf(FileInfo), SHGFI_DISPLAYNAME);
          Listitem.Caption := FileInfo.szDisplayName;

          SHGetFileInfo(PChar(strPath + SearchRec.Name), 0, FileInfo, SizeOf(FileInfo), SHGFI_TYPENAME);
          ListItem.SubItems.Add(FileInfo.szTypeName);

          SHGetFileInfo(PChar(strPath + SearchRec.Name), 0, FileInfo, SizeOf(FileInfo), SHGFI_ICON or SHGFI_SMALLICON);
          icon.Handle := FileInfo.hIcon;

          ListItem.ImageIndex := ImageList.AddIcon(Icon);
          ImageList.AddIcon(Icon);
          DestroyIcon(FileInfo.hIcon);

          Application.ProcessMessages;
        end;
      end;
      i := FindNext(SearchRec);
    end;
  finally
    Icon.Free;
    ListView.Items.EndUpdate;
  end;
end;


Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
var
  SHFileInfo: TSHFileInfo;
  SysIcons: THandle;
begin
  try
    SysIcons := SHGetFileInfo(PChar(copy(ParamStr(0), 1, 3)), 0, SHFileInfo, SizeOf(SHFileInfo), SHGFI_SYSICONINDEX or SHGFI_SMALLICON or SHGFI_ICON);
  finally
    DestroyIcon(SHFileInfo.hIcon);
  end;
  ImgLst.Handle := SysIcons;
end;
Miniaturansicht angehängter Grafiken
imglst_146.gif  
Doreen
Gruss Doreen
  Mit Zitat antworten Zitat