Page 1 of 1
ListIconGadget speed
Posted: Wed Apr 29, 2020 5:55 pm
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.
Re: ListIconGadget speed
Posted: Wed Apr 29, 2020 6:07 pm
by skywalk
Search incremental load listicongadget / listviewgadget.
There is no need to load that many rows.
Only load what can be showed within the viewable scroll area.
Re: ListIconGadget speed
Posted: Wed Apr 29, 2020 6:32 pm
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
Re: ListIconGadget speed
Posted: Wed Apr 29, 2020 6:36 pm
by Kiffi
skywalk wrote:There is no need to load that many rows.

+1
Re: ListIconGadget speed
Posted: Wed Apr 29, 2020 6:42 pm
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
Re: ListIconGadget speed
Posted: Wed Apr 29, 2020 6:51 pm
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
Re: ListIconGadget speed
Posted: Wed Apr 29, 2020 8:50 pm
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.
Re: ListIconGadget speed
Posted: Wed Apr 29, 2020 10:03 pm
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)
Re: ListIconGadget speed
Posted: Wed Apr 29, 2020 10:20 pm
by harkon
Thanks Barry. I really appreciate it.
Re: ListIconGadget speed
Posted: Thu Apr 30, 2020 9:09 am
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
Re: ListIconGadget speed
Posted: Wed May 24, 2023 7:51 pm
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)