ListIconGadget speed

Just starting out? Need help? Post your questions and find answers here.
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

ListIconGadget speed

Post by harkon »

Hey guys. I've got a ListIconGadget I need to populate with 70,000 (give or take) items. I was using Listview for this, but it runs out of space and can't handle that many items.

In populating the items, it takes a really long time. It was faster in XP and Windows 7, but under Windows 10 it takes a long time. Is there a way to speed up how fast we can populate such a list?

It was fast enough when I only had 30,000 but it's annoyingly slow now.

Any help is greatly appreciated.
Missed it by that much!!
HK
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: ListIconGadget speed

Post by skywalk »

Search incremental load listicongadget / listviewgadget.
There is no need to load that many rows. :shock:
Only load what can be showed within the viewable scroll area.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
morosh
Enthusiast
Enthusiast
Posts: 329
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: ListIconGadget speed

Post by morosh »

when populating, turn display off:
SendMessage_(GadgetID(#ListIcon),#WM_SETREDRAW,0,0)

at finish, turn it on:
SendMessage_(GadgetID(ListIcon),#WM_SETREDRAW,1,0)

HTH
PureBasic: Surprisingly simple, diabolically powerful
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: ListIconGadget speed

Post by Kiffi »

skywalk wrote:There is no need to load that many rows. :shock:
+1
Hygge
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: ListIconGadget speed

Post by davido »

@harkon,

Please have a look at ListEx gadget by Thorsten1867.
It allows one to stop the gadget updating on the screen during the population.
It should load in 70,000 in a fraction of a second; at least that is my experience.

https://www.purebasic.fr/english/viewto ... 73#p533673
DE AA EB
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: ListIconGadget speed

Post by netmaestro »

For quick loading of large datasets to a listicon gadget the key is #LVS_OWNERDATA. This is generally known as a "virtual listicon". You can search it on the forums for examples, here's one I found that didn't work and needed a couple tweaks:

Code: Select all

itemcount.i = 70000
Global Dim myItems.s(0)
#LVSICF_NOINVALIDATEALL = 1
#LVN_ODCACHEHINT = #LVN_FIRST - 13

Procedure WinCallback(hwnd, msg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Static field.s
  Select msg
    Case #WM_NOTIFY
      *pnmh.NMHDR = lParam
      Select *pnmh\code
        Case #LVN_ODCACHEHINT
          result = 0
        Case #LVN_GETDISPINFO                ;
          *pnmlvdi.NMLVDISPINFO = lParam
          If *pnmlvdi\item\mask & #LVIF_TEXT
            line.s = myItems(*pnmlvdi\item\iItem)
            If line
              field = StringField(line, *pnmlvdi\item\iSubItem+1, #LF$)
            EndIf
            *pnmlvdi\item\pszText = @field
            ;
          EndIf         
      EndSelect
  EndSelect
  ProcedureReturn result
EndProcedure

If OpenWindow(0, 100, 100, 800, 600, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SetWindowCallback(@WinCallback())
  ListIconGadget(0, 5, 5, 780, 390, "A", 250,#LVS_OWNERDATA) 
  SendMessage_(GadgetID(0), #LVM_SETITEMCOUNT, 0, #LVSICF_NOINVALIDATEALL)
  AddGadgetColumn(0, 1, "B", 255)
  AddGadgetColumn(0, 2, "C", 200)
 
  SendMessage_(GadgetID(0), #LVM_SETITEMCOUNT, ItemCount+1, #LVSICF_NOINVALIDATEALL)     
 
  For pos = 0 To itemcount
    ReDim myItems(pos)
    myItems(pos) = Str(pos) + #LF$ + "This is a bunch of text for "+Str(pos) + #LF$ + "This is a bunch more text"
  Next
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
BERESHEIT
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Re: ListIconGadget speed

Post by harkon »

Thanks Netmeastro, that worked 100%. The project is cross platform and Linux has no issues with loading that many items into a listview. Windows was limited to the max number of items in the listview so I needed to use listicon. Rolled your code into my project and boom, starts right up.

With listicon, is there a way to eliminate the title row? If not it's no big deal.
Missed it by that much!!
HK
BarryG
Addict
Addict
Posts: 4127
Joined: Thu Apr 18, 2019 8:17 am

Re: ListIconGadget speed

Post by BarryG »

harkon wrote:is there a way to eliminate the title row?
Specify the #LVS_NOCOLUMNHEADER flag for no ListIconGadget() header.

Code: Select all

ListIconGadget(0, 5, 5, 780, 390, "A", 250,#LVS_OWNERDATA|#LVS_NOCOLUMNHEADER)
harkon
Enthusiast
Enthusiast
Posts: 217
Joined: Wed Nov 23, 2005 5:48 pm

Re: ListIconGadget speed

Post by harkon »

Thanks Barry. I really appreciate it.
Missed it by that much!!
HK
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: ListIconGadget speed

Post by Shardik »

harkon wrote:The project is cross platform ...
harkon wrote:With listicon, is there a way to eliminate the title row?
Cross-platform example
User avatar
Blue
Addict
Addict
Posts: 964
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: ListIconGadget speed

Post by Blue »

morosh wrote: Wed Apr 29, 2020 6:32 pm when populating, turn display off:
at finish, turn it on:
Fabulous !!!
Thanks for this very simple solution.
Works perfectly for my needs (loading 15K-20K data lines into a ListView)
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
Post Reply