@Trond
It looks like you asked the same question as me, in following your other topic
http://www.purebasic.fr/english/viewtop ... 88#p369888 (ScrollBarGadget can't reach max?).
DoubleDutch gave me an answer that gave me a solution from RASHAD through a search in the forum:
http://www.purebasic.fr/english/viewtop ... nt#p353306.
The difference with srod's solution is that RASHAD's code is portable (no APIs), but using a simple Thread.
Code below is from RASHAD, I modified it to have two scrollbars, and see if it can work with one Thread.
Code: Select all
;(c) Rashad 2011-05-22
; this will show in 'real-time' the current scrollbar position
Procedure Scrollbar(parameter)
Repeat
SetGadgetText(1,Str(GetGadgetState(2)))
SetGadgetText(4,Str(GetGadgetState(5)))
Delay(40)
ForEver
EndProcedure
OpenWindow(0, 0, 0, 305, 140, "ScrollBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Vstart.i=50
TextGadget (0, 10,15, 220, 20, "VScrollBar Position : ",#PB_Text_Right)
TextGadget (1, 230,15, 20, 20, Str(Vstart),#PB_Text_Right)
ScrollBarGadget (2, 270, 10, 25, 120 ,0, 101, 1, #PB_ScrollBar_Vertical)
SetGadgetState (2,Vstart)
Hstart.i=20
TextGadget (3, 0,90, 120, 20, "HScrollBar Position : ",#PB_Text_Right)
TextGadget (4, 120,90, 20, 20, Str(Hstart),#PB_Text_Right)
ScrollBarGadget (5, 0, 110, 270, 20 ,0, 101, 1)
SetGadgetState (5,Hstart)
AddKeyboardShortcut(0, #PB_Shortcut_Up,10)
AddKeyboardShortcut(0, #PB_Shortcut_Down,11)
Thread = CreateThread(@Scrollbar(), 15)
ThreadPriority(Thread, 1)
Repeat
Select WaitWindowEvent(1)
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Menu
Select EventMenu()
Case 10
SetGadgetState(2,GetGadgetState(2) - 1)
SetGadgetText(1,Str(GetGadgetState(2)))
Case 11
SetGadgetState(2,GetGadgetState(2) + 1)
SetGadgetText(1,Str(GetGadgetState(2)))
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case 2
EndSelect
EndSelect
Until Quit = 1
CloseWindow(0)
Different approaches, same result.
Cheers!