It is currently Thu May 23, 2013 4:38 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Proper ListIconGadget locking to prevent greying out?
PostPosted: Mon Apr 16, 2012 8:52 am 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 3011
I have one list populating with 2,000 items at program startup and the following two sets of ways are partially successful at stopping the 'greying out' or non-responsiveness of the list while loading but the list is still 'grey' for a short while and doesn't look nice.

This

LockWindowUpdate_(GadgetID(#DocList)) ; Lock the list
LockWindowUpdate_(0) ; Unlock the list

or

SendMessage_(GadgetID(#DocList), #WM_SETREDRAW, #False, 0)
SendMessage_(GadgetID(#DocList), #WM_SETREDRAW, #True, 0)

There was an example in the forum to subclass the gadget to stop all redraw messages but I don't know what it was called.

Does anyone know of a better, more effective way than the above?

_________________
Resist FaceBorg or have your ass laminated!


Top
 Profile  
 
 Post subject: Re: Proper ListIconGadget locking to prevent greying out?
PostPosted: Mon Apr 16, 2012 8:59 am 
Offline
New User
New User

Joined: Sat Apr 14, 2012 5:40 pm
Posts: 7
Why not simply hide the gadget until you are done populating it?


Top
 Profile  
 
 Post subject: Re: Proper ListIconGadget locking to prevent greying out?
PostPosted: Mon Apr 16, 2012 9:51 am 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 3011
hazard wrote:
Why not simply hide the gadget until you are done populating it?


I hide the whole form for aesthetics but obviously not long enough. Too long and it would not look right.

The subclassing option is better and someone may remember it.

or, might need to do something other than load so many records on start but I like the gadget visible and not greyed out so the subclassing option sounds good. At least there is a visible 'face' to the program while work is being done.

_________________
Resist FaceBorg or have your ass laminated!


Top
 Profile  
 
 Post subject: Re: Proper ListIconGadget locking to prevent greying out?
PostPosted: Mon Apr 16, 2012 10:30 am 
Offline
New User
New User

Joined: Sat Apr 14, 2012 5:40 pm
Posts: 7
I am not really sure how subclassing to prevent redrawing will cure the 'non-responsiveness' because, even if you disable all painting, your program is still going to have to wait whilst the list is populated.

You could populate the list within some timer or other or...

Code:
If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  AddGadgetColumn(0, 1, "Column", 250)
  For i = 0 To 10000
    AddGadgetItem(0, -1, "Item " + Str(i))
    WindowEvent() : Delay(1)
  Next
  Repeat
    Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
 EndIf


Top
 Profile  
 
 Post subject: Re: Proper ListIconGadget locking to prevent greying out?
PostPosted: Mon Apr 16, 2012 11:41 am 
Offline
User
User

Joined: Sat Dec 27, 2008 9:42 pm
Posts: 10
Location: Bulgaria
A good aproach when adding so much items is to use multithreading. Adding items asynchroniously will update gadget's window and keep the gadget responsive.
Code:
Procedure additems(param)
      For i = 0 To 10000
          AddGadgetItem(0, -1, "Item " + Str(i))
         
  Next
EndProcedure

If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  AddGadgetColumn(0, 1, "Column", 250)
 
  CreateThread(@additems(), 0)
  Repeat
    Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
 EndIf

_________________
µHash


Top
 Profile  
 
 Post subject: Re: Proper ListIconGadget locking to prevent greying out?
PostPosted: Mon Apr 16, 2012 1:09 pm 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 3011
criobot wrote:
A good aproach when adding so much items is to use multithreading. Adding items asynchroniously will update gadget's window and keep the gadget responsive.
Code:
Procedure additems(param)
      For i = 0 To 10000
          AddGadgetItem(0, -1, "Item " + Str(i))
         
  Next
EndProcedure

If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  AddGadgetColumn(0, 1, "Column", 250)
 
  CreateThread(@additems(), 0)
  Repeat
    Event = WaitWindowEvent()
 Until Event = #PB_Event_CloseWindow
 EndIf


I don't know much about threads having not used them in many years but it sounds like a good approach.

1 question though...I remember that there is a single string buffer in pb so what happens if something else wants to use the gadget when the thread is operating (posting other strings to it from other parts of my program)? Am I opening a whole can of worms here?

When a thread is finished, does it just exit and clean up after itself?

_________________
Resist FaceBorg or have your ass laminated!


Top
 Profile  
 
 Post subject: Re: Proper ListIconGadget locking to prevent greying out?
PostPosted: Mon Apr 16, 2012 1:47 pm 
Offline
New User
New User

Joined: Sat Apr 14, 2012 5:40 pm
Posts: 7
Set the threadsafe compiler switch and the compiler will automatically generate code in which each thread uses it's own string buffer.


Top
 Profile  
 
 Post subject: Re: Proper ListIconGadget locking to prevent greying out?
PostPosted: Mon Apr 16, 2012 1:51 pm 
Offline
PureBatMan Forever
PureBatMan Forever

Joined: Tue Feb 10, 2004 3:07 am
Posts: 2265
Location: Ohio, USA
Thanks for bringing this topic up Fangles. It helped me to remember a few things about speeding up my ListIconGadget in my current project.

Where are you pulling the data from? How many columns in the ListIcongadget? How long is it talking to load?

I'm pulling in 3900 lines of 3 columns each from a .csv file in under half a second. I use the #WM_SETREDRAW messages to help speed things up from 2.5 seconds.

_________________
What goes around comes around.

PB 4.40(x64) - Windows 7 Home Premium 64


Top
 Profile  
 
 Post subject: Re: Proper ListIconGadget locking to prevent greying out?
PostPosted: Mon Apr 16, 2012 2:50 pm 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 3011
Quote:
Thanks for bringing this topic up Fangles. It helped me to remember a few things about speeding up my ListIconGadget in my current project.


Any time master. Been a while since I 'saw' you and i'm between blood tests so had to think.

Currently, 1899 records. Data will go up shortly!!!

Quote:
Where are you pulling the data from?


From an SQLite database

Quote:
How many columns in the ListIcongadget?


15 columns

Quote:
How long is it talking to load?


4.5 seconds. And as there will be many more in the future, this is already too long.

Quote:
I'm pulling in 3900 lines of 3 columns each from a .csv file in under half a second. I use the #WM_SETREDRAW messages to help speed things up from 2.5 seconds.


That's pretty impressive.

I'm currently using the :

SendMessage_(GadgetID(#Gadget_DocMan_DocumentList), #WM_SETREDRAW, #False, 0)

before the mass display and

SendMessage_(GadgetID(#Gadget_DocMan_DocumentList), #WM_SETREDRAW, #True, 0)

Afterwards.

P.S. Nice to hear from you again!

_________________
Resist FaceBorg or have your ass laminated!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye