ScrollBarGadget can't reach max?

Just starting out? Need help? Post your questions and find answers here.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

ScrollBarGadget can't reach max?

Post by Trond »

I just can't scroll to the end. Is this really right?

Code: Select all

W = 512
H = 384
OpenWindow(0, 0, 0, W, H, "", #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)

ScrollBarGadget(0, 10, 10, 480, 17, 0, 100, 25)

Repeat
  Event = WaitWindowEvent()
  Select Event
    Case #PB_Event_Gadget
      Debug GetGadgetState(0) ; Never shows above 75
    Case #PB_Event_CloseWindow
      CloseWindow(0)
      Break
  EndSelect
ForEver
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: ScrollBarGadget can't reach max?

Post by srod »

Yes that is absolutely right.

The scrollbar you have set up would be appropriate for viewing say a text document with 100 lines (indexed 0 to 99). Because of your page size of 25 then the highest recordable scrollbar value would be 99 + 1 - 25 = 75. This is how the page-sizes work.

When the scrollbar state is 0 then your page size of 25 means that lines 0 to 0 + 25 -1 or lines 0 to 24 would be on view.

When the scrollbar state is 75 then your page size of 25 means that lines 75 to 75 + 25 -1 or lines 75 to 99 would be on view and this is exactly right.
I may look like a mule, but I'm not a complete ass.
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: ScrollBarGadget can't reach max?

Post by charvista »

What srod answered is true...
I played with the code to see if I could display the percentage in real time in the TextGadget while dragging the scrollbar. But no success... Only when I drop the mouse button, the percentage is showed.
The reason is to be able to see when I should drop the mouse button.
Thanks

Code: Select all

W = 512
H = 384
Win=OpenWindow(#PB_Any,0,0,W,H,"",#PB_Window_ScreenCentered|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget)
    TxGad=TextGadget(#PB_Any,10,40,100,20,"0")
    SbGad=ScrollBarGadget(#PB_Any, 10, 10, 480, 17, 0, 100, 25)
    Percent=0
    Repeat
        Event = WaitWindowEvent()
        Select Event
            Case #PB_Event_Gadget
                Select EventGadget()
                    Case SbGad
                        If EventType()=#PB_EventType_LeftClick  ;does not work with #PB_EventType_Change
                            SetGadgetText(TxGad,Str(GetGadgetState(SbGad)))
                        EndIf
                EndSelect
            Case #PB_Event_CloseWindow
                Quit=1  
        EndSelect
    Until Quit=1
CloseWindow(Win)
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: ScrollBarGadget can't reach max?

Post by DoubleDutch »

Having 'live' events from the scroll bars has been requested - there are workarounds, but nothing 'native'.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: ScrollBarGadget can't reach max?

Post by charvista »

Thank you DoubleDutch!!!
With your answer, I could make a search with the term "live" and "scrollbar" to find the fantastic solution from RASHAD (dumb up, my friend!) here: http://www.purebasic.fr/english/viewtop ... nt#p353075
Cheers!
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: ScrollBarGadget can't reach max?

Post by DoubleDutch »

np. :)

You should +1 the request to add native support. :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply