Page 1 of 1
Memory Issue... List Gadgets <_<
Posted: Mon Dec 08, 2008 5:11 pm
by funnyguy
I use the following code
Code: Select all
If OpenWindow(0, 0, 0, 640, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
; left column
list=ListIconGadget(#PB_Any,10,10,620,280,"ID",50)
AddGadgetColumn(list,2,"Name",50)
For i=0 To 1000000
AddGadgetItem(list,-1,Str(i)+Chr(10)+"Name"+Str(i))
Next i
; Here we change the ListIcon display to large icons and show an image
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
But my app uses close 170MB!!

I don't want it using that much..
Posted: Mon Dec 08, 2008 5:20 pm
by Fred
1 Million entries, so what ?
Posted: Mon Dec 08, 2008 5:58 pm
by AndyMK
lol
Posted: Mon Dec 08, 2008 6:13 pm
by Demivec
Ha, good one!

Posted: Mon Dec 08, 2008 6:46 pm
by Sparkie
Here's a quick and dirty virtual ListIconGadget...
Code: Select all
;... Use 1000000 items
#ItemCount = 1000000
#LVSICF_NOINVALIDATEALL = 1
#LVN_ODCACHEHINT = #LVN_FIRST - 13
;... Array to hold data
Global Dim myItems.s(#ItemCount,1)
Procedure WinCallback(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
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
;... Item text is being requested
*pnmlvdi\item\pszText = @myItems(*pnmlvdi\item\iItem,*pnmlvdi\item\iSubItem)
EndIf
EndSelect
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 640, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
SetWindowCallback(@WinCallback())
; left column
list=ListIconGadget(#PB_Any,10,10,620,280,"ID",50,#LVS_OWNERDATA)
;... Set desired number of ListIconGdaget items
SendMessage_(GadgetID(list), #LVM_SETITEMCOUNT, #ItemCount, #LVSICF_NOINVALIDATEALL)
AddGadgetColumn(list,2,"Name",100)
For i=0 To #ItemCount
myItems(i,0) = Str(i)
myItems(i,1) = "Name"+Str(i)
Next i
; Here we change the ListIcon display to large icons and show an image
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Posted: Mon Dec 08, 2008 7:05 pm
by srod
I don't understand why you need the SetGadgetItemText()s Sparks?
Surely the whole point of a virtual control is that the callback supplies the text?
Posted: Mon Dec 08, 2008 7:16 pm
by Sparkie
You're absolutely correct srod. That was the
dirty of quick and dirty.
I've edited the original code and I thank you sir for your keen eye.

Posted: Mon Dec 08, 2008 7:18 pm
by srod
Sparkie wrote:You're absolutely correct srod. That was the
dirty of quick and dirty.
I've edited the original code and I thank you sir for your keen eye.

Aye, I am forever on the lookout for quick and dirty....... uhm, not sure that sounds right somehow?

Posted: Mon Dec 08, 2008 7:23 pm
by Sparkie
Sounds about right for you my friend.

Posted: Mon Dec 08, 2008 7:26 pm
by srod
Sparkie wrote:Sounds about right for you my friend.

I agree!

Posted: Mon Dec 08, 2008 9:56 pm
by blueznl
srod wrote:
Aye, I am forever on the lookout for quick and dirty....... uhm, not sure that sounds right somehow?
Well, I dunno... sounds kinda' right to me

Posted: Wed Dec 10, 2008 2:56 pm
by pdwyer
Thanks sparkie, I've been wondering about a virtual listview in PB. This reminded me and demo'd it all at once
An interesting article about virtual listview controls
http://blogs.msdn.com/cumgranosalis/arc ... Usage.aspx
Posted: Wed Dec 10, 2008 4:16 pm
by rsts
Very interesting. I had also seen your other post on virtual lists (Sparkie) and am considering using them in an app I have which needs to refresh a list of potententially many thousand items, which can be a little sluggish.
What are the downsides to virtual lists?
cheers