Reputation: 313
I'm dealing with the mathematical logic of scroll bars in windows. To be specific I don't know what a variable means. The scroll bar logic goes like this:
(thumb-size / scroll-bar-size) = (page-size / scroll-bar-range)
Now, I'm wondering what the scroll-bar-range is. I know what the range of a scroll bar is though. But I dont know how this helps to put that into the formula. Because we have a range from [0...n] and not a single value. We have multiple values Zero, one, two through n.
For example if I have a scrollbar range defined like this:
SCROLLINFO si;
si.nMin = 0; // minimum value of scroll-bar-range
si.nMax = 50; // maximum value of scroll-bar-range
si.nPage = 25; // page-size
How would I put the range into the above formula? Assuming that the range in this case is [0..50]. I don't know if that is correct but that is what my inituition tells me.
Anyway, in this case the page-size would be 25. But what have I to substitute for the scroll-bar-range in the above formula? is it 51? That would give:
25 / 51
Thanks guys.
Upvotes: 0
Views: 438
Reputation: 15375
The range is nMax-nMin+1! So it is 51.
In fact Setting nMin=0 nMax=50 and nPage to 25. will cause nPos to be in the range between 0 and 26! http://msdn.microsoft.com/en-us/library/windows/desktop/bb787595(v=vs.85).aspx
The reason is that if nPos (the top line) is on index 26 you have 25 lines from 26 to to number 50 on that page-.
In your sample the quotient 25/51 tells the System that the tumb area will cover 21/51 of the full (1.0) space of the scroll bar. Because the size of the thumb Shows the relative page Position in the scrollable area.
HTH
Upvotes: 1