Board index » delphi » Small (16x16) associated icons

Small (16x16) associated icons

Hi,

I'm using the ExtractAssociatedIcon function to get the icons associated
with files. However, these icons are 32x32, while I need the 16x16
icons. Manually (with an imagelist) resizing the icons to 16x16 results
in distorted icons.
How can I retrieve the associated 16x16 icons?

--

Pieter van Erp
Oss, THE NETHERLANDS

    "It ain't over 'till the Fat Lady sings"

Take a look at FinanceNet: summaries of economic and financial papers
  [ http://home.hccnet.nl/p.a.v.erp ]

(to reply, please remove the NOSPAM section from by e-mail)

 

Re:Small (16x16) associated icons


Use the following procedure to copy the associated small icon of a file to a
bitmap (e.g. Image1.Picture.Bitmap).

procedure GetIcon(FileName: String; Bitmap: TBitmap);
var
  ImageList: HImageList;
  FileInfo: SHFileInfo;
  X, Y: Integer;
begin
  ImageList := SHGetFileInfo(PChar(ExtractFilePath(FileName)), 0, FileInfo,
SizeOf(FileInfo),
    SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
  ImageList_GetIconSize(ImageList, X, Y);
  Bitmap.Height := X;
  Bitmap.Width := Y;
  Bitmap.TransparentMode := tmFixed;
  Bitmap.TransparentColor := clFuchsia;
  Bitmap.Canvas.Brush.Color := Bitmap.TransparentColor;
  Bitmap.Canvas.FillRect(Rect(0, 0, X, Y));
  SHGetFileInfo(PChar(FileName), 0, FileInfo, SizeOf(FileInfo),
    SHGFI_SYSICONINDEX or SHGFI_ICON or SHGFI_SMALLICON);
  ImageList_Draw(ImageList, FileInfo.iIcon, Bitmap.Canvas.Handle, 0, 0,
    ILD_TRANSPARENT);
end;

"Pieter van Erp" <p.a.v.erp@hccnet*NOSPAM*.nl> schreef in bericht
news:8avuff$g2u$1@news.hccnet.nl...

Quote
> Hi,

> I'm using the ExtractAssociatedIcon function to get the icons associated
> with files. However, these icons are 32x32, while I need the 16x16
> icons. Manually (with an imagelist) resizing the icons to 16x16 results
> in distorted icons.
> How can I retrieve the associated 16x16 icons?

> --

> Pieter van Erp
> Oss, THE NETHERLANDS

>     "It ain't over 'till the Fat Lady sings"

> Take a look at FinanceNet: summaries of economic and financial papers
>   [ http://home.hccnet.nl/p.a.v.erp ]

> (to reply, please remove the NOSPAM section from by e-mail)

Re:Small (16x16) associated icons


Quote
"M.H. Avegaart" wrote:
> Use the following procedure to copy the associated small icon of a file to a
> bitmap (e.g. Image1.Picture.Bitmap).
> <cut>

It's working like a charm, thanks!!

--

Pieter van Erp
Oss, THE NETHERLANDS

    "It ain't over 'till the Fat Lady sings"

Take a look at FinanceNet: summaries of economic and financial papers
  [ http://home.hccnet.nl/p.a.v.erp ]

(to reply, please remove the NOSPAM section from by e-mail)

Other Threads