June 30, 2024, 05:29:32 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Getscrollpos and Setscrollposs question

Started by Andy, February 12, 2014, 06:38:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

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


LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

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.

:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

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.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.