Wrox Programmer Forums
|
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
 
Old November 6th, 2006, 08:36 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default 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
 
Old November 7th, 2006, 03:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 7th, 2006, 10:05 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks marcostraf,
Where do I put this calculation? Also, what do I assign correctValue to?

Thanks again,

Kevin

dartcoach
 
Old November 8th, 2006, 03:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

???
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
 
Old November 10th, 2006, 07:01 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old November 10th, 2006, 10:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 10th, 2006, 11:51 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old November 13th, 2006, 02:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 13th, 2006, 09:30 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Marcostraf,

Thanks very much! Got it and it works great!

Thanks again!

Kevin

dartcoach





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create ScrollBar for HTML DIV Adawi VB How-To 3 March 26th, 2008 10:05 AM
create scrollbar albraham123 HTML Code Clinic 1 May 18th, 2007 09:16 AM
Create custom DOM functions for IE ? paultman BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 2 October 13th, 2005 09:45 AM
How to create a custom window shape lotfi VS.NET 2002/2003 1 November 17th, 2003 08:13 AM
How to create a custom form shape lotfi BOOK: Professional C#, 2nd and 3rd Editions 0 November 15th, 2003 08:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.