473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I use scrollbars if their maximum isn't really the maximum?

I have been struggling with .NET's scrollbars because when I use them I can't
seem to get them to go to their maximum value.

Searching on the web it looks like the maximum Value you can get on your
scrollbar is actually it's Maxmimum - LargeChange + 1. So when I set my
scrollbar's Maximum to the height of the image I want to scroll, it always
falls short of the bottom LargeChange pixels. Thisis because when I draw the
image I set it's Location to be the engative of the horizontal/vertical
scrollbars so the visible area within the ClientRectangle is offset by the
scrollbar positions.

So what do I need to do to hack this to work?

One thing I can do is set the scrollbars LargeChange to 1, but obviously
this is bad because the thumb tab is always tiny.

Another thing I can do is override the scrollbar's WndProc function and
"fix" it so it actually honors the Maximum value instead of the bizarre
Maximum - LargeChange + 1 logic. But I found it to be confusing because while
there is a nice way to figure out when you click one of the arrow buttons up
or down (the wParam would be 0 or 1,) when you drag the thumb tab you get
these giant numbers which doent immediately indicate whether it's being
dragged up or down, it's very strange.

But all the .NET controls can't possibly hacking it like this, how the heck
do they get their controls to display nicely ? What am I doing wrong?

As an example, I made a small program with a user control that has my own
scrollbars to scroll an image with a thick red border up and down. Notice how
if you use the scrollbar controls like the thumb tab or the arrow keys,
you'll NEVER be able to get the bottom red border to show up because the
scroll value is never able to reach its maximum value due to the way it's
logic is written.

it's code is here: http://pastehere.com/?xmdtbe

try running it and see for yourself and then if you see what I did wrong
please let me know so I can put this issue behind me!

thanks!
Nov 9 '06 #1
2 4334
I had a similar issue, and here is how I handled it:

private void vertScroll_Scroll(object sender, ScrollEventArgs e)
{
ScrollVertical(e.NewValue);
}

protected virtual void ScrollVertical(int newValue)
{
pagePanel.Top = Math.Min(Math.Max(-vertScroll.Maximum, -newValue), 0);
}

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
"MrNobody" <Mr******@discussions.microsoft.comwrote in message
news:AD**********************************@microsof t.com...
>I have been struggling with .NET's scrollbars because when I use them I
can't
seem to get them to go to their maximum value.

Searching on the web it looks like the maximum Value you can get on your
scrollbar is actually it's Maxmimum - LargeChange + 1. So when I set my
scrollbar's Maximum to the height of the image I want to scroll, it always
falls short of the bottom LargeChange pixels. Thisis because when I draw
the
image I set it's Location to be the engative of the horizontal/vertical
scrollbars so the visible area within the ClientRectangle is offset by the
scrollbar positions.

So what do I need to do to hack this to work?

One thing I can do is set the scrollbars LargeChange to 1, but obviously
this is bad because the thumb tab is always tiny.

Another thing I can do is override the scrollbar's WndProc function and
"fix" it so it actually honors the Maximum value instead of the bizarre
Maximum - LargeChange + 1 logic. But I found it to be confusing because
while
there is a nice way to figure out when you click one of the arrow buttons
up
or down (the wParam would be 0 or 1,) when you drag the thumb tab you get
these giant numbers which doent immediately indicate whether it's being
dragged up or down, it's very strange.

But all the .NET controls can't possibly hacking it like this, how the
heck
do they get their controls to display nicely ? What am I doing wrong?

As an example, I made a small program with a user control that has my own
scrollbars to scroll an image with a thick red border up and down. Notice
how
if you use the scrollbar controls like the thumb tab or the arrow keys,
you'll NEVER be able to get the bottom red border to show up because the
scroll value is never able to reach its maximum value due to the way it's
logic is written.

it's code is here: http://pastehere.com/?xmdtbe

try running it and see for yourself and then if you see what I did wrong
please let me know so I can put this issue behind me!

thanks!

Nov 9 '06 #2
If you have an image on 100 pixels by 100pixels. Set the maximum to 109 and
the large change to 10. this will enable the bars to scroll to 100.
Just a thought. I always used to have the issue of the Scroll event being
called more than once per scroll.
Ciaran O'Donnell

"MrNobody" wrote:
I have been struggling with .NET's scrollbars because when I use them I can't
seem to get them to go to their maximum value.

Searching on the web it looks like the maximum Value you can get on your
scrollbar is actually it's Maxmimum - LargeChange + 1. So when I set my
scrollbar's Maximum to the height of the image I want to scroll, it always
falls short of the bottom LargeChange pixels. Thisis because when I draw the
image I set it's Location to be the engative of the horizontal/vertical
scrollbars so the visible area within the ClientRectangle is offset by the
scrollbar positions.

So what do I need to do to hack this to work?

One thing I can do is set the scrollbars LargeChange to 1, but obviously
this is bad because the thumb tab is always tiny.

Another thing I can do is override the scrollbar's WndProc function and
"fix" it so it actually honors the Maximum value instead of the bizarre
Maximum - LargeChange + 1 logic. But I found it to be confusing because while
there is a nice way to figure out when you click one of the arrow buttons up
or down (the wParam would be 0 or 1,) when you drag the thumb tab you get
these giant numbers which doent immediately indicate whether it's being
dragged up or down, it's very strange.

But all the .NET controls can't possibly hacking it like this, how the heck
do they get their controls to display nicely ? What am I doing wrong?

As an example, I made a small program with a user control that has my own
scrollbars to scroll an image with a thick red border up and down. Notice how
if you use the scrollbar controls like the thumb tab or the arrow keys,
you'll NEVER be able to get the bottom red border to show up because the
scroll value is never able to reach its maximum value due to the way it's
logic is written.

it's code is here: http://pastehere.com/?xmdtbe

try running it and see for yourself and then if you see what I did wrong
please let me know so I can put this issue behind me!

thanks!
Nov 9 '06 #3

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

Similar topics

24
by: Nobody | last post by:
Okay, you are all so smart in here. Answer me this: IE6 in standards mode doesn't seem to hide scrollbars on the body element (overflow:hide) Ain't this a quandary. I have it in my head that I...
5
by: Duane Lambe | last post by:
Hi - just a quick question, I hope it's simple enough that a visual example isn't required. I have an internal site, everything's the way I want it, but there's an anomoly in both Opera and...
1
by: Kristof Nachtergaele | last post by:
Hi, I'm looking for something, which acts as a container, that I can drop onto my form and which has a size that is bigger than the visible part, the invisible pazrt being scrollable to with...
8
by: Pauli Østerø | last post by:
I have a serious problem. I have made an Control which draws a blueprint of a building and a related SpotMatrix. I have made it possible to zoom in on the blueprint and scroll around if the size...
10
by: GTi | last post by:
I have a popup window, If this window is to smaal the scrollbars is visible. Is there any JavaScript available so I can check if the scrollbars is visible on page (right and bottom side)? Then I...
2
by: Ernst Elzas | last post by:
Hello, If these questions have been asked numerous times before, please excuse me, I have not managed to find the information I needed. I'm making a webpage (for now it will only be in two...
3
by: John Kraft | last post by:
I have a listview control that I want the columns of to remain a proportional size filling the listview completely. In the listview's Resize method, I calculate the new sizes and all looks fine....
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
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 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...

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.