Re: ListIconGadget speed
Posted: Wed Apr 29, 2020 6:51 pm
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