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!