` Printed Icetips Article

Icetips Article



Par2: Controlling horizontal scroll bar in code
2000-06-14 -- Maarten
 
I'm getting a DejaVu feeling from this message
> Somehow I need to control the horizontal scrollbar in a list box from a
Since you want to solve this the hard way......
Your biggest problem is that the horizontal scrollbar doesn't fire
an event whatsoever (with or without the IMM-atrib on the listbox),
so we'll have to make those ourselves;)

On the Window (not the listbox) Alrt() the LeftKey and the RightKey.
Activate the horizontal scrollbar on the listbox.
Place a region over the scrollable part of this scrollbar.
Place buttons exactly over the horizontal scroll-buttons
with ICON:VCRplay on the left- and ICON:VCRback on
the right-button, so you won't see any difference with the
original horizontal scrollbar.
Those buttons plus the region must be *before* the
listbox in the window control order.
In the accepted embed for the left-button enter:
      PRESSKEY(LeftKey)
      SELECT(?List1)
In the accepted embed for the right-button enter:
      PRESSKEY(RightKey)
      SELECT(?List1)
And finally in the EVENT:AlertKey embed of the Window:
        LOC:HorScr = ?List1{PROP:HScrollPos}
        IF KeyCode() = RightKey
          IF LOC:HorScr < 50
            LOC:HorScr += 7
            ?List1{PROP:HScrollPos} = LOC:HorScr
          ELSE
            CYCLE
          END
        END
        IF KeyCode() = LeftKey
          IF LOC:HorScr > 6
            LOC:HorScr -= 7
            ?List1{PROP:HScrollPos} = LOC:HorScr
          ELSE
            CYCLE
          END
        END
        DISPLAY(?List1)

And you're done:)   (tested code!)
Now when the user presses Cursor_Right, the listbox
will scroll 7 columns to the left. This also happens when
he presses the right-arrow on your horizontal scrollbar
(well... he presses your button but he doesn't know that).
And, the thumb on the scroll bar goes to the right as well:)



Printed November 23, 2024, 2:05 am
This article has been viewed/printed 35395 times.