The following example allows to scroll up/down/left/right page by page by using the buttons - but the how to calculate the magic number to do stepping correctly? As soon some lines are inserted (by pressing the button '+') or the width of the gadget will be changed, the values have to be recalculated.
Code: Select all
LoadFont(0,"Tahoma",14)
si.SCROLLINFO
OpenWindow(0,0,0,420,250,"Window",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
ListIconGadget(1,0,0,200,250,"",1000)
TextGadget(2,310,10,100,25,"")
TextGadget(3,310,40,100,25,"")
TextGadget(4,310,70,100,25,"")
TextGadget(5,310,100,100,25,"")
ButtonGadget(10,345,180,30,25,"+")
ButtonGadget(11,310,180,30,25,"<")
ButtonGadget(13,345,150,30,25,"^")
ButtonGadget(12,380,180,30,25,">")
ButtonGadget(14,345,210,30,25,">")
AddWindowTimer(0,0,250)
SetGadgetFont(1,FontID(0))
text$ = "yiuy ioy oiuoi uoiu oiu oiu uoi io oi uo yioioiyiuyui iouioioiyoiyoiyoiy oiy oiy oiy o yoiy oiyoiy "
For i = 0 To 15
AddGadgetItem(1, -1, Str(i)+" "+text$)
Next
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_Gadget,#PB_Event_Menu
e=EventGadget()
Select e
Case 10
AddGadgetItem(1, -1, text$)
Case 11,12
px=GetScrollPos_(GadgetID(1),#SB_HORZ)
magic=181
SetScrollPos_(GadgetID(1),#SB_HORZ,px+ magic *(1-(e&1)<<1),#True)
Case 13,14
py=GetScrollPos_(GadgetID(1),#SB_VERT)
magic=7
SetScrollPos_(GadgetID(1),#SB_VERT,py+ magic *(1-(e&1)<<1),#True)
EndSelect
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Timer
px=GetScrollPos_(GadgetID(1),#SB_HORZ)
py=GetScrollPos_(GadgetID(1),#SB_VERT)
GetScrollRange_(GadgetID(1),#SB_HORZ,@dummy,@wx)
GetScrollRange_(GadgetID(1),#SB_VERT,@dummy,@wy)
SetGadgetText(2,"PX: "+Str(px))
SetGadgetText(3,"PY: "+Str(py))
SetGadgetText(4,"WX: "+Str(wx))
SetGadgetText(5,"WY: "+Str(wy))
EndSelect
Until Quit = 1