[RESOLVED] Scrollbar thumb (slider) size.
Can anyone help me with a scroll bar problem.
I have a picture within a form which has an HScroll and VScroll scroll bars but the size of the thumb or slider isn't proportional to the missing portion of the picture.
I know it has to do with the
HScroll1.SmallChange
HScroll1.LargeChange
VScroll1.SmallChange
VScroll1.LargeChange
variables but I just don't understand them. No matter what I do to test on them it doesn't make sense.
Basically I need the variables to be a function of the form size and the picture size. ie form1.height/picture1.height
At the same time can someone explain what the difference between picture.height and picture.scaleheight?
Re: Scrollbar thumb (slider) size.
It sounds like you need to set the scroll bars max and min properties to reflect the image size... the small change is the value change when you click the arrow and the large change is the value change when you click between the arrow and the slider
Re: Scrollbar thumb (slider) size.
I found some code on microsoft's web site for adding scroll bars to a picture. Here is the link to the thread. I still don't understand how to modify it to get it working correctly. They have
VB Code:
HScroll1.Max = Picture1.Width - VScroll1.Left
VScroll1.Max = Picture1.Height - HScroll1.Top
Has anyone any suggestions on how to change it so that it starts with a long slide bar as soon as form1.width<picture1.width?
Re: Scrollbar thumb (slider) size.
Well, if you post your code, then we should be able to help you better.
But as a general rule, I would calcuate the smallchange and largechange like this:
VB Code:
HScroll1.SmallChange = HScroll1.Max * 0.01
If HScroll1.SmallChange <= 0 Then HScroll1.SmallChange = 1
HScroll1.LargeChange = HScroll1.Max * 0.1
If HScroll1.LargeChange <= 0 Then HScroll1.LargeChange = 1
Use the same formula for the VScroll1
1 Attachment(s)
Re: Scrollbar thumb (slider) size.
Quote:
Originally Posted by sgrya1
At the same time can someone explain what the difference between picture.height and picture.scaleheight?
You can change the scale, and it won't change the actual size of the picturebox.
Scale is used the set the "virtual" size of the picturebox
For example, if you have a picturebox with height 100, you can set it's ScaleHeight to 1000, then any object that you put INSIDE the picturebox, will have a size depending on it's scale, so if you put another object inside the picturebox, and you make it the same size as the picturebox, then it's height will be 1000 because it's parent picturebox has it's scale to 1000.
Anyways, I also attached a picture, maybe you will understand better when you actually see the sample numbers...
1 Attachment(s)
Re: Scrollbar thumb (slider) size.
Thanks CVMichael.
Sort of understood why a picture needed to have scales but that explains it very clearly.
Attached is a shell of a project with your suggestions.
There's something wrong now with the max properties assigned to the scroll bars. Can you please look at it to see what is wrong.
1 Attachment(s)
Re: Scrollbar thumb (slider) size.
I made quite a few changes, see if you like it ?
1 Attachment(s)
Re: Scrollbar thumb (slider) size.
Thanks for looking at it but I still need some adjustments.
Attached is the original.
With the original the scroll bars are not visible until the size of the form is less than the size of the picture. This is what I want. But the problem is that as soon as the form is smaller than the picture the sliders appear but are about 1/5 of the size of the form. I'd like it so that that as when the form is a little bit smaller than the size of the picture, the sliders appear but are almost the length of the form and reduce when the form is resized smaller. Can you please look at it again?
Re: Scrollbar thumb (slider) size.
Is anyone able understand what is wrong with the slider code? It's driving me nuts.
Below is the explaination for the paramaters but it seems that they are bugged. No matter what I change it doesn't do what I think it should.
Parameters
Min Usually set to zero or one
Max Set this to the number of rows in the file minus the number of rows displayed. If you want to scroll past the last row, then set it larger.
Value Where the slider is located.
LargeChange Amount Value is changed when the user clicks above or below the slider, or presses PgUp or PgDn keys.
SmallChange Amount Value is changed when the user clicks an arrow or presses the up and down arrow keys.
1 Attachment(s)
Re: Scrollbar thumb (slider) size.
I finally understand what you wanted, you want to scroll when the form is smaller than the picture, not the other way around (as I originally understood)
But it looks OK to me...
I made the SmallChange and LargeChange static, maybe that's the result you want, take a look
I also placed some lines in the picture box, to be able to actually see it moving around
2 Attachment(s)
Re: Scrollbar thumb (slider) size.
Thanks again CVMichael. I might be getting pedantic about it but it still isn't behaving like normal windows sliders.
For example in Word if half the page is missing, the slider is half the length of the scrollbar but the in the example posted it is about 1/10th.
1 Attachment(s)
Re: Scrollbar thumb (slider) size.
I've found an answer but I don't understand how it works. It was just a stab that seems to do the trick.
VB Code:
HScroll1.SmallChange = Picture1.Width / 10
HScroll1.LargeChange = Picture1.Width / 2
VScroll1.SmallChange = Picture1.Height / 10
VScroll1.LargeChange = Picture1.Height / 2
Thanks for your help again. You showed me what I should be tweaking.
Re: Scrollbar thumb (slider) size.
Maybe this is what your looking for ?
VB Code:
HScroll1.SmallChange = Picture1.Width / 10
HScroll1.LargeChange = Picture1.Width - HScroll1.Max
VScroll1.SmallChange = Picture1.Height / 10
VScroll1.LargeChange = Picture1.Height - VScroll1.Max
Re: Scrollbar thumb (slider) size.
YEP! That's it! :)
Thankyou. Sorta think I understand it too.
Re: [RESOLVED] Scrollbar thumb (slider) size.
CVMichael,
Not sure why this bug is occuring. Hoping you can help me out again.
Every now and again when I switch to a different application I come back to my progam to find that I get an error saying run-time error "380"
"Invalid Property Value"
When I press the debug button it flags
VScroll1.LargeChange = Picture1.Height - VScroll1.Max
as being the problem.
I'd like to shell down my program to show it to you but was wondering if you had any ideas before I try.
Re: [RESOLVED] Scrollbar thumb (slider) size.
It's probably because the value that is assigned to the VScroll1.LargeChange is less than 1.
This happens especially when you minimize the form, or maximize it, also when you make the form too small.
Just ignore the error, or I should say, just make the program ignore the error
So, at the beginning of Form_Resize(), put this:
VB Code:
Private Sub Form_Resize()
On Error Resume Next
' .... the rest of the code
I always do that in the Form_Resize(), it's the only time when I actually want to ignore an error :)