Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: AsleyCruz on March 17, 2020, 11:57:36 pm

Title: Can't get large icon ListView report
Post by: AsleyCruz on March 17, 2020, 11:57:36 pm
Team

My ListView1 has ViewStyle = vsReport, LargeImages = ImageList1.
and an ImageList1 Width and Height = 32.

How can I load large icon of a file on ImageList1?

The below code suppose to load large icon (32x32) but the icons look distorted (see attached image).

Code: Pascal  [Select][+][-]
  1. SHGetFileInfoW(PWideChar(FilePath), 0, FileInfo, SizeOf(FileInfo), SHGFI_DISPLAYNAME or SHGFI_TYPENAME or SHGFI_ICON or SHGFI_LARGEICON);

Please, help me find any solution.
Thanks a lot!
Title: Re: Can't get large icon ListView report
Post by: wp on March 18, 2020, 12:09:39 am
Your code is Windows-only. I would do it in the Lazarus way:
Code: Pascal  [Select][+][-]
  1.   ImageList1.GetIcon(imageindex, ico);  // ico is a pre-created TIcon
Of course, I don't know what you are doing exactly, but my attached demo works correctly.

Regarding your screenshot: it looks as if you added smaller images to the 32x32 image list. The Lazarus image list is different from the Delphi image list in that it accepts images at different sizes and scales them to the size specified (or even several sizes if you click "Add resolution" in the imagelist editor dialog).
Title: Re: Can't get large icon ListView report
Post by: AsleyCruz on March 18, 2020, 12:18:37 am
Your code is Windows-only. I would do it in the Lazarus way:
Code: Pascal  [Select][+][-]
  1.   ImageList1.GetIcon(imageindex, ico);  // ico is a pre-created TIcon
Of course, I don't know what you are doing exactly, but my attached demo works correctly.

Thanks wp, works great but I wasnt clear.
I want to...
- Get icon 32x32 of any file
- Save the loaded icon on the ImageList1.
- Apply the loaded icon to ListView in vsReport mode.
TinyPortal © 2005-2018