ListIconGadget display corruption
Posted: Wed Jan 06, 2021 2:15 pm
I've got a ListIconGadget in Large Icons mode where I added icons on-the-fly, but after adding a few, the display gets "corrupted" until I force a refresh by changing the mode from Large to List and then back to Large again.
To see what I mean, run this code. Then press the "A" key at least 8 times, and then scroll down the list and you'll see that the icons aren't in order (it has gaps, see screenshot below). Then press the "F" key to fix the display, and then "A" works normally.
I'm hoping there's a way to fix the display without changing the mode? Any ideas?

To see what I mean, run this code. Then press the "A" key at least 8 times, and then scroll down the list and you'll see that the icons aren't in order (it has gaps, see screenshot below). Then press the "F" key to fix the display, and then "A" works normally.
I'm hoping there's a way to fix the display without changing the mode? Any ideas?

Code: Select all
If OpenWindow(0, 200, 200, 320, 185, "ListIconGadget", #PB_Window_SystemMenu)
ListIconGadget(1, 10, 10, 305, 165, "", 250, #PB_ListIcon_MultiSelect | #PB_ListIcon_AlwaysShowSelection)
If LoadImage(0, #PB_Compiler_Home+"Examples\Sources\Data\File.bmp")
SetGadgetAttribute(1, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
text$ = "Notepad"
id = ImageID(0)
For i = 1 To 3
AddGadgetItem(1, 1, text$, id)
Next
EndIf
Repeat
Event = WaitWindowEvent()
If Event = #WM_KEYUP
Select EventwParam()
Case #VK_A
AddGadgetItem(1, -1, text$, id)
Case #VK_F ; Hack "fix". How to do this without changing the DisplayMode?
SetGadgetAttribute(1, #PB_ListIcon_DisplayMode, #PB_ListIcon_List)
SetGadgetAttribute(1, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf