Recent

Author Topic: TShellListView empty space artifact after setting .Mask  (Read 1589 times)

BrunoK

  • Hero Member
  • *****
  • Posts: 762
  • Retired programmer
Re: TShellListView empty space artifact after setting .Mask
« Reply #15 on: December 03, 2025, 04:52:39 pm »
Lazarus Trunk, Fpc 3.2.2

I modified a bit the project and now I can't reproduce the problem and that surprises me because there is nothing indicating what could have made things work.

And an other point is that the project does not work well on linux.


wp

  • Hero Member
  • *****
  • Posts: 13334
Re: TShellListView empty space artifact after setting .Mask
« Reply #16 on: December 03, 2025, 07:42:12 pm »
Strange... Ran my own test project for comparison - it shows the issue, your's doesn't. I thought it might be the btnChDirClick in FormCreate, but commenting it out makes no difference.

Ran your project under Linux with qt5 qt6, gtk3 (these x11) and with gtk2 (wayland). Qt5 and qt6 are correct, gtk2 and gtk3 display only the Type column - is this what you are meaning with "does not work well on Linux"? This is because the other columns have a width of 1 px only. Found out that this originates in "AdjustColWidths" which gets zero ListView's ClientWidth in gtk2/gtk3 when it is called. Added another call in TShellListView.Loaded, and this fixes the issue.

BrunoK

  • Hero Member
  • *****
  • Posts: 762
  • Retired programmer
Re: TShellListView empty space artifact after setting .Mask
« Reply #17 on: December 03, 2025, 08:42:21 pm »
Strange... Ran my own test project for comparison - it shows the issue, your's doesn't. I thought it might be the btnChDirClick in FormCreate, but commenting it out makes no difference.
May be it is that the original poster had a change of mask and a change of root in the same  control click. But I haven't been able to see why that should affect things.
I tried to modify win32callback.inc and add a WM_SETREDRAW: DoMsgRedraw; that calls ListView_EnsureVisible but if I remember, it successfully displayed the contents but the icons did also disappear after a few calls.

Quote
and with gtk2 ...  display only the Type column - is this what you are meaning with "does not work well on Linux"?
Yes

Glad that you saw the same issues because sometimes I get the feeling of being lost.

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: TShellListView empty space artifact after setting .Mask
« Reply #18 on: December 04, 2025, 01:19:16 am »
I have been studying the code in the Win32wsshellctrls and I don't think the use of the ListView_GetImageList and set_ImageList is correct?

 In code, the list view image list is created when it is detected that it does not exists, so the current image index that was returned from the system per current filename introduced will trigger a creation of the list, and add that one image from the system image handle to it.

 But I only see one image being added so something is strange here.

 Normally you create an image list, add all the images to that list while enumerating, free each handle as you go, and in the end, assign that image list to the ListView_SetImageList and now you have an attached list.

 On top of that, when refreshing the list via a different ext for example, I don't think that list ever gets reloaded with new icons, because it already exists with the prior one, this can lead the list to not having the indexed item in it and do all sorts of nice things.

 I would thing the list needs to be purged between refreshes.

 Maybe I am overloading something, but this isn't working from what I can see.

Please look here at an C example.

https://learn.microsoft.com/en-us/windows/win32/controls/add-list-view-image-lists

Jamie


 

 
« Last Edit: December 04, 2025, 01:27:49 am by jamie »
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 13334
Re: TShellListView empty space artifact after setting .Mask
« Reply #19 on: December 04, 2025, 11:17:59 am »
In code, the list view image list is created when it is detected that it does not exists, so the current image index that was returned from the system per current filename introduced will trigger a creation of the list, and add that one image from the system image handle to it.
Created? I would not call it like that. It is a system imagelist which exists independently of the ListView. As far as I understand, the code in TWin32WSCustomShellListView.GetBuiltInImageIndex only assigns the handle of this system imagelist to the ListView (via ListView_SetImageList).

But I only see one image being added so something is strange here.
No image is "added" to this imagelist. SHGetFileInfoW only gets some file info record which contains the image index for the given file in that system imagelist. And the image index is all the Listview needs to display an icon for that file. And of course, this functions is called again and again during the listview population phase for each file added.

Normally you create an image list, add all the images to that list while enumerating, free each handle as you go, and in the end, assign that image list to the ListView_SetImageList and now you have an attached list.
Normally, yes. But not here. Simply speaking: the function just finds the image index for a given file in an system-wide existing imagelist. There were several discussions about this topic; https://forum.lazarus.freepascal.org/index.php?topic=31625.0 is one of them.

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: TShellListView empty space artifact after setting .Mask
« Reply #20 on: December 04, 2025, 12:20:14 pm »
Okay I'm going to drop out of this thread because it's obviously it's not going anywhere for me I'll just not use that control.
 thank you very much your hard work.
Jamie.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018