By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,558 Members | 1,399 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,558 IT Pros & Developers. It's quick & easy.

Why can't I scroll back to the maximum value?

P: n/a
I'm using the VScrollBar and set it as follow:

m_vScrollBar.Minimum = -19602;
m_vScrollBar.Maximum = 0;
m_vScrollBar.SmallChange = 1;
m_vScrollBar.LargeChange = 1089;
m_vScrollBar.Value = m_vScrollBar.Maximum;

The scroll bar is set to start from the bottom.

It works fine but with one problem which I can't figure out.

After I scroll up, no matter the way I scroll up, I can't scroll back to the
zero value which is the Maximum value of the scroll bar.

It does start with the zero value, but when I try to scroll back down to the
bottom, the maximum value I get in the value of LargeChange as minus (-1089).
But I need it to get to zero.

Why is that happening?

How can I fix that?
--
Thanks
Sharon
May 15 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Tue, 15 May 2007 00:42:00 -0700, Sharon <Sh*****@newsgroups.nospam>
wrote:
[...]
It does start with the zero value, but when I try to scroll back down to
the bottom, the maximum value I get in the value of LargeChange as minus
(-1089). But I need it to get to zero.

Why is that happening?

How can I fix that?
Funky, isn't it? :)

The "LargeChange" value generally corresponds to a full screen worth of
view onto whatever is being scrolled. For example, you've got a document
that is essentially 1000 pixels high, shown in a window 100 pixels high.
Then you'd set LargeChange to 100.

At the same time, typically you'd use the scroll bar value as a negative
offset for drawing your document. Since to show the last 100 pixels of
the 1000 pixel high document, you'd want an offset of -900, the scroll bar
limits its travel to between 0 (top of the document) and 900 (bottom of
the document). That is, even though the maximum value for the scroll bar
is 1000, it only winds up varying up to 900.

In other words, the Maximum value for the scroll bar isn't really the
maximum value the scroll bar can be set to...it's the maximum value that
represents the very end of your *view* onto whatever data you're scrolling.

There are a variety of ways to deal with this, but the most obvious is
simply to adjust the Maximum value so that when the LargeChange is
subtracted, you get the actual maximum value you'd like from the scroll
bar. In other words, just set Maximum to 1089.

For what it's worth, this sort of funny business with scroll bars has been
going on since the earliest days of scroll bars. No matter which way an
API defines the scroll bar behavior, someone will come along expecting it
to work the other way. The trick is just figuring out which
implementation the scroll bar you're using picked, and work with it. :)

Pete
May 15 '07 #2

P: n/a
Thanks for your help.

I'm not sure I fully understand what uou mean.

I'm using the scroll bar not to show the numbers of screen pixels of the
window, I'm using it to scroll the number of data rows the controls (my own
control) has.
The Window contains 3 controls, each control contain 363 rows, that is why
I'm setting the LargeChange to 1089 (2 * 363). I'm also using the scroll bar
value for reference to a specific row in one of the shown controls.
There are many control ( 19602 / 363 = 54 controls) I need to scroll, and
for every LargeChange, 3 other control are shown.
So I need the scroll bar to move in value range of 0 to 19602. It starts
nicety at zero, but after I scroll up, I can't scroll back down to zero. I
can only scroll back to 1089.

If I'll set the Maximum to 1089, I will not be able to get the zero value
(or below 1089) in order to get to the first control.
I hope this extra info wasn't too much and that it helps us some more.

What do you think I should to make it work as I described above?
--
Thanks
Sharon
May 16 '07 #3

P: n/a
On Wed, 16 May 2007 01:33:01 -0700, Sharon <Sh*****@newsgroups.nospam
wrote:
I'm using the scroll bar not to show the numbers of screen pixels of the
window, I'm using it to scroll the number of data rows the controls (my
own control) has.
Pixels, text lines, controls, it doesn't matter. I used pixels as an
example, but no matter the units, you (should) have a way of measuring how
many of those units fit on a single screen, and the LargeChange value is
typically the same as that number of units.

In your case, you appear to claim to have 1089 rows of data on your
screen, so that's the number you picked. That's fine, all of the same
concepts apply.
The Window contains 3 controls, each control contain 363 rows, that is
why I'm setting the LargeChange to 1089 (2 * 363). I'm also using the
scroll
bar value for reference to a specific row in one of the shown controls..
Gracious...what is the vertical resolution of your display, that you can
fit 1089 rows of data on a single screen?

Anyway, I'll take it as granted that you do. Even so, the same thing
applies.
There are many control ( 19602 / 363 = 54 controls) I need to scroll, and
for every LargeChange, 3 other control are shown.
So I need the scroll bar to move in value range of 0 to 19602. It starts
nicety at zero, but after I scroll up, I can't scroll back down to zero.
I can only scroll back to 1089.
You don't actually need a scroll bar to move in the value range of 0 to
19602, not if I understand your counting correctly. Given your assertion
that you can fit 1089 units (rows of data in this case) in the window ata
time, the 1089 value for LargeChange seems fine. But the value of the
scroll bar should be the index for the data displayed at the top of the
window, and when you are viewing the last page of your data, the index of
the data at the top of the window is not actually your maximum value
(19602, you say), but rather than minus the number of units viewable in
the space of the window (19602 - 1089, in this case).

And of course, that is what the scroll bar does for you.
If I'll set the Maximum to 1089, I will not be able to get the zero value
(or below 1089) in order to get to the first control.
You originally wrote that you had set the scroll bar range to be -19602 to
0. If you want the value to vary between those two numbers, the maximum
actually needs to be set to 1089 when the LargeChange is set to 1089.
Then the user will be able to change the scroll bar position enough to
allow the value for the scroll bar to reach 0.

Now, if you want to change the parameters of the problem as you have here
and now claim that the range of the scroll bar is from 0 to 19602, then of
course you will have to use a different maximum value (19602 + 1089, in
this case) so that the scroll bar value can actually get as high as 19602.

Regardless of the range of your scroll bar, the key is to add the
LargeChange value to the nominal maximum value to get the number you
assign to the Maximum property. That will allow the user to be able to
vary the scroll bar between the full range of values you are using.
I hope this extra info wasn't too much and that it helps us some more.

What do you think I should to make it work as I described above?
As I have said, you have to add your LargeChange value to the maximum
value you want the scroll bar to take on, and use that new value to set
the Maximum property.

Now, that said please note what I wrote above about how the UI normally
works. Different programs use scroll bars differently, but usually a
scroll bar can only be scrolled down so that the very last part of
whatever you're viewing is visible at the very bottom of the screen.
That's why the scroll bar behaves the way it does.

If you adjust the Maximum value so that the scroll bar value can actually
range from 0 to the number of units in your data, then the user will be
able to scroll your data all the way off the screen. If this is what you
want, then it's fine to fudge the Maximum value to allow it. If it's not
what you want, then the scroll bar is already doing the correct thing and
you should not be trying to "fix" it.

By the way, this is all documented in what I think is a reasonably clear
way, in the description for the VScrollBar.Maximum property:

"The value of a scroll bar cannot reach its maximum value through
user interaction at run time. The maximum value that can be reached
is equal to 1 plus the Maximum property value minus the LargeChange
property value. The maximum value can only be reached programmatically"

Note also the implication of this: the scroll bar's value *can* reach the
Maximum if you modify it programmatically. That means that if you do
fudge the value, you need to be careful if and when you modify it
programmatically (for example, in response to the Page Up and Page Down
keys) and restrict the value to the true maximum. Otherwise, the user
will be able to scroll the data a full page *beyond* being off the screen,
which could result in some serious confusion.

Pete
May 16 '07 #4

P: n/a

Thanks. Thanks. Thanks a lot.

It's works fine now as you said you it would.
----------------
Thanks Again
Sharon
May 16 '07 #5

P: n/a
Now I have a smaller problem.
The data rows I told you about are zero indexed, so I had to set the Minimum
value of the scroll bar to 19601, which 1 less the the previous value. So now
the scroll bar is set as follow:

m_vScrollBar.Minimum = 19601; // decreased by 1
m_vScrollBar.Maximum = 1089; // instead of zero of my last post.
m_vScrollBar.SmallChange = 1; // the same.
m_vScrollBar.LargeChange = 1089; // the same.
m_vScrollBar.Value = 0; // the same.

If I use the scroll bar by it's LargeChange, I get up and down values as it
supposed to.

But if I drag the bar up and then all the way down, it does not get to the
zero value, it gets to value of 1. And from this point on, I can not scroll
it to the zero value.

What am I doing wrong this time?
--
Thanks
Sharon
May 17 '07 #6

P: n/a
I think I found how it should be set:

m_vScrollBar.Minimum = -19601; // decreased by 1
m_vScrollBar.Maximum = 1088; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
m_vScrollBar.SmallChange = 1; // the same.
m_vScrollBar.LargeChange = 1089; // the same.
m_vScrollBar.Value = 0; // the same.

And now its working great.
(a littel lunch break did the job...)
--
Thanks
Sharon
May 17 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.