Add to ListIconGadget index 0 with large icons

Just starting out? Need help? Post your questions and find answers here.
BarryG
Addict
Addict
Posts: 3320
Joined: Thu Apr 18, 2019 8:17 am

Add to ListIconGadget index 0 with large icons

Post by BarryG »

Adding an item to a ListIconGadget's index 0 position fails in Large Icon mode. The hack solution (as first shown by Rashad in a related thread here) is to set the gadget to List mode before adding, then set it back to Large Icon mode. Please fix so this hack isn't needed, because I just spent hours trying to get this to work before I remembered Rashad's tip.

The bug:

Code: Select all

If OpenWindow(0, 200, 200, 300, 100, "ListIcon", #PB_Window_SystemMenu)
  ListIconGadget(0, 5, 5, 290, 90, "Name", 100)
  SetGadgetAttribute(0, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
  AddGadgetItem(0, -1, "bbb")
  AddGadgetItem(0, -1, "ccc")
  AddGadgetItem(0, 0, "aaa") ; Why not in first position (index 0) ?
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Rashad's hack fix:

Code: Select all

If OpenWindow(0, 200, 200, 300, 100, "ListIcon", #PB_Window_SystemMenu)
  ListIconGadget(0, 5, 5, 290, 90, "Name", 100)
  SetGadgetAttribute(0, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
  AddGadgetItem(0, -1, "bbb")
  AddGadgetItem(0, -1, "ccc")
  SetGadgetAttribute(0, #PB_ListIcon_DisplayMode, #PB_ListIcon_List)
  AddGadgetItem(0, 0, "aaa") ; Now it's in first position (index 0). Bah.
  SetGadgetAttribute(0, #PB_ListIcon_DisplayMode, #PB_ListIcon_LargeIcon)
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Fred
Administrator
Administrator
Posts: 16681
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Add to ListIconGadget index 0 with large icons

Post by Fred »

Seems to be a Windows oddity, the position seems to be ignored in this case when calling LVM_INSERTITEM.
Post Reply