IonicWind Software

IWBasic => General Questions => Topic started by: Andy on February 12, 2014, 06:38:16 AM

Title: Getscrollpos and Setscrollposs question
Post by: Andy on February 12, 2014, 06:38:16 AM
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.
Title: Re: Getscrollpos and Setscrollposs question
Post by: LarryMc on February 12, 2014, 07:44:51 AM
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


Title: Re: Getscrollpos and Setscrollposs question
Post by: Andy on February 13, 2014, 01:38:44 AM
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.
Title: Re: Getscrollpos and Setscrollposs question
Post by: Andy on February 13, 2014, 04:01:46 AM
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.

:)
Title: Re: Getscrollpos and Setscrollposs question
Post by: LarryMc on February 13, 2014, 04:09:25 AM
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
Title: Re: Getscrollpos and Setscrollposs question
Post by: Andy on February 13, 2014, 09:14:16 AM
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.
:)