473,605 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

I'm using the VScrollBar and set it as follow:

m_vScrollBar.Mi nimum = -19602;
m_vScrollBar.Ma ximum = 0;
m_vScrollBar.Sm allChange = 1;
m_vScrollBar.La rgeChange = 1089;
m_vScrollBar.Va lue = m_vScrollBar.Ma ximum;

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
6 10661
On Tue, 15 May 2007 00:42:00 -0700, Sharon <Sh*****@newsgr oups.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 "LargeChang e" 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
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
On Wed, 16 May 2007 01:33:01 -0700, Sharon <Sh*****@newsgr oups.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.Maxi mum 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 programmaticall y"

Note also the implication of this: the scroll bar's value *can* reach the
Maximum if you modify it programmaticall y. That means that if you do
fudge the value, you need to be careful if and when you modify it
programmaticall y (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

Thanks. Thanks. Thanks a lot.

It's works fine now as you said you it would.
----------------
Thanks Again
Sharon
May 16 '07 #5
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.Mi nimum = 19601; // decreased by 1
m_vScrollBar.Ma ximum = 1089; // instead of zero of my last post.
m_vScrollBar.Sm allChange = 1; // the same.
m_vScrollBar.La rgeChange = 1089; // the same.
m_vScrollBar.Va lue = 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
I think I found how it should be set:

m_vScrollBar.Mi nimum = -19601; // decreased by 1
m_vScrollBar.Ma ximum = 1088; // !!!!!!!!!!!!!!! !!!!!!!!!!!!!!! !!!!!
m_vScrollBar.Sm allChange = 1; // the same.
m_vScrollBar.La rgeChange = 1089; // the same.
m_vScrollBar.Va lue = 0; // the same.

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
13941
by: laurie | last post by:
Hi. I have a DIV section that has many thumbnail images inside it. I have a DIV so all images can fit in a row and the horizontal scroll bar is used to move the thumbnails from left to right. Does anyone know any code to have the DIV scroll from left to right when I use an onmouseover on two images either side of the DIV? Thanks Laurie
2
1810
by: GrantS | last post by:
I am trying to convert the VB.Net code example povided by http://authors.aspalliance.com/JimRoss/Articles/MaintainScrollPos.aspx into C# (ASP.Net)without success. No errors are thrown in the VB code provided on the website. Once I have this example running correctly, I will need to use the concept in a more complex project. The code I am using involves an webform and an htc file. The code for ScrollPos.htc (which is located in a folder...
6
10928
by: Colin McGuire | last post by:
Hello experts, this is a repost but I have been (much) more clear. I want to know the position of the horizontal scrollbar in a textbox as a percentage - if the horizontal scrollbar is hard left, I want to display 0% on the form. - if the horizontal scrollbar is smack in the middle, I want to display 50% on the form. - if the horizontal scrollbar is 2/3rd along the X-axis,
1
265
by: Doug | last post by:
I use the following code to add a vScrollbar to a form. How do I get it so if the form height is changed, the scroll bar maximum is changed to reflex then new size. The lastControl is the last Control on the form, which would be the height of the form. I call this on resize of the form. It works fine it the form is not resized. If the form is shortened, the scroll bar does not scroll down to the last control. It the form is lengthened, the...
6
4858
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
1
2093
by: Wayne Sepega | last post by:
Ultimately what I need is a way to remember the scroll position of the form on a post back. I have a button that posts back to the current form and if there are no errors the form is reproduced, I want to scroll back to where the user was when they clicked on the button. I have an ASPX page with the following doc type: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
5
1731
by: MLH | last post by:
I have a vehicle entry form with a combo box for choosing the owner. Let's say the user opens the list by clicking the arrow then choose the owner by clicking a name. That much works fine. But the problem begins here... If for some reason, the user is uncertain of his first choice of an owner and decides to drop the list down again, using his keyboard up 'n down arrows to scroll the list, browsing for other owner choices until he's...
11
2264
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server 6.something I think and running as a service, Using NoteTab Pro as an IDE (works well). If you need more, just ask. In one functioning form:
4
3379
by: Paul Engel | last post by:
I have an application on which I have a tab control with two tabs. When a user double-clicks on an item in tab1 of my tabs collection, tab2 becomes the visible tab. (tabImageTabs.SelectedIndex = 1) When they double-click on the content in tab2, they are taken back to tab1. (tabImageTabs.SelectedIndex = 0) When tab1 is restored, I have lost the position of the scrollbar and the user must re-scroll to get back to where they were. I've...
0
7999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7931
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8423
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8411
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8281
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5885
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3911
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1530
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.