Recent

Author Topic: Can't get large icon ListView report  (Read 338 times)

AsleyCruz

  • Jr. Member
  • **
  • Posts: 78
    • Graphic and apps designer
Can't get large icon ListView report
« 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!
AsleyCruz - Graphic and apps designer
-
http://www.asleycruz.com/

wp

  • Hero Member
  • *****
  • Posts: 7353
Re: Can't get large icon ListView report
« Reply #1 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).
« Last Edit: March 18, 2020, 12:16:41 am by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

AsleyCruz

  • Jr. Member
  • **
  • Posts: 78
    • Graphic and apps designer
Re: Can't get large icon ListView report
« Reply #2 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.
AsleyCruz - Graphic and apps designer
-
http://www.asleycruz.com/

 

TinyPortal © 2005-2018