 |
VB How-To Ask your "How do I do this with VB?" questions in this forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

November 6th, 2006, 08:36 PM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Create Custom ScrollBar
Hi All,
Does anyone out there know how to create a custom scrollbar? I've got a form with 2 picture boxes. I've used the included scrollbars.
The problem arises when I load my form, the height of the picture box may exceed the 32767 limit.
I started thinking that there may be a way to have a command button and when it's clicked on(and the mouse button is held down), the user can drag it down or up, and the top of the scrolling picture on the form goes up and down based on the movement of the mouse.
Please Help.
Thanks in advance.
Kevin
dartcoach
__________________
dartcoach
|

November 7th, 2006, 03:46 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
you do not have to create a custom one.
if the size of the picture is bigger than 32767, set the scrollbar max to 32767, and then scale its value:
correctValue = cdbl(scrollbar.value) * pictureSize / 32767.0
I use double to avoid math overflow
|

November 7th, 2006, 10:05 PM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Thanks marcostraf,
Where do I put this calculation? Also, what do I assign correctValue to?
Thanks again,
Kevin
dartcoach
|

November 8th, 2006, 03:23 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
???
you do not have to assign correctValue, that is computed...
I guess in your Scroll event you shift the picture using scrollbar.Value
well, instead of using that, use the formula I geve to you to get the "real" scrollbar value (i.e. the one associated with the loaded picture)
let me know if I has been more clear this time
|

November 10th, 2006, 07:01 PM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
marcostraf,
You are correct that I am shifting the picture. That's the only way I know how.
Could you tell me the code in the scroll event I should be using?
Thanks in advance.
Kevin
dartcoach
|

November 10th, 2006, 10:19 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I already answer your question... sorry for my English, but I cannot be more clear than that
please post a snippet of the code you are using to shift the image, and I'll tell you how to modify it
|

November 10th, 2006, 11:51 PM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Private Sub VScroll1_Change()
Me.Picture1.Top = -VScroll1.Value
End Sub
Private Sub VScroll1_Scroll()
Me.Picture1.Top = -VScroll1.Value
End Sub
These are the two I currently have.
Thanks again.
Kevin
dartcoach
|

November 13th, 2006, 02:55 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Private Sub VScroll1_Change()
Me.Picture1.Top = -cdbl(VScroll1.value) * pictureHeight / 32767.0.Value
End Sub
where picture Height is the height of your image.
remember to set the Max value of the scrollbar to 32767
|

November 13th, 2006, 09:30 PM
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Marcostraf,
Thanks very much! Got it and it works great!
Thanks again!
Kevin
dartcoach
|
|
 |