Hi,
I have a window called "dy", and a listbox "747".
I'm using @idtimer (every 2 seconds) to delete all contents of the listbox and re-populate it.
When the listbox is re-populated the scroll bar (vertical) go back to the top, how can I keep the scroll bar position where the user places the button after the listbox is re-populated?
Listbox is populated using "Addstring", and I'm trying to use "Getscrollpos" and "Setscrollpos" commands with no luck.
Obviously I've looked at the examples that come with IW but can't make it work.
Can anyone show me an example please.
Thanks,
Andy.
I couldn't find anything that told me how to get the scroll position of a Listbox; maybe someone else can come up with something.
The best I can do is suggest you reposition the list so that the same indexed item is shown at the top of the listbox
Just before erasing the current contents use this line of code
lb_index =sendmessage( dy,LB_GETTOPINDEX ,0,0,747)
and immediately after repopulating the listbox you use this line of code
sendmessage( dy,LB_SETTOPINDEX ,lb_index,0,747)
that should do what you want as long as the listbox contains the same number of lines each time
Thanks Larry for that suggestion,
I'm now using a scrollbar to get around this, will post it when I can figure out this little problem:
Deletestring doesn't seem to be working correctly or is it me?
Please see attached program.
I would expect to see nothing, but instead some string still appear? ???
Thanks,
Andy.
It seems you have to delete the strings in reverse order:
FOR zzz = GETSTRINGCOUNT(dy,747) to 0 STEP -1
DELETESTRING dy,747,zzz
NEXT zzz
This works!
Andy.
:)
Looking at your code:
FOR zzz = 0 to 4
DELETESTRING dy,747,zzz
NEXT zzz
when you delete the first entry (zzz=0) the remaining entries move up
so you have entries at 0 thru 3
when you delete zzz=1 the remaining entries move up
so now you have entries at 0 thru 2
and so on...
fix in one of three ways
FOR zzz = 0 to 4
DELETESTRING dy,747,0
NEXT zzz
or
FOR zzz = 4 to 0 step -1
DELETESTRING dy,747,zzz
NEXT zzz
or
sendmessage dy,LB_RESETCONTENT,0,0,747
Thanks Larry,
I used the second option for x = nnn to 0 step -1 etc.
Have uploaded an alternative task manager in user offering utilising tips and tricks from yourself and Sapero.
Thanks,
Andy.
:)