VB Scrollbar Question

I have a innerpicture in a outerpicture on a form and the innerpicture is bigger than the viewing size, I want to be able to center these picture on a form and use the scrollbars to move the innerpicture around so I can see the whole thing when I scroll, without the inner picture bleeding over onto the outerpicture, anyone have any suggestions?
Thanks
Jerry
ockwig@ureach.com
OckwigAsked:
Who is Participating?
 
DocMConnect With a Mentor Commented:
Check this out:

HOWTO: Scroll a Form When VB Forms Are Limited to Screen Size

http://support.microsoft.com/default.aspx?scid=kb;en-us;109741 
0
 
DocMCommented:
Check this out:

HOWTO: Scroll a Form When VB Forms Are Limited to Screen Size

http://support.microsoft.com/default.aspx?scid=kb;en-us;109741 
0
 
DocMCommented:
This page will be more appropriate.
HOWTO: Create Scrollable Viewports
http://support.microsoft.com/default.aspx?scid=kb;en-us;186429
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
DeAnConnect With a Mentor Commented:
with the following controls on a form:
2 PictureBoxes: picInner, picOuter
1 VScrollBar: VScroll1
1 HScrollBar: HScroll1

Private Sub Form_Resize()
  picOuter.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
  VScroll1.Move picOuter.Width - (picOuter.Width - picOuter.ScaleWidth) - VScroll1.Width, 0, VScroll1.Width, picOuter.ScaleHeight
  HScroll1.Move 0, picOuter.Height - (picOuter.Height - picOuter.ScaleHeight) - HScroll1.Height, picOuter.ScaleWidth - VScroll1.Width, HScroll1.Height
  VScroll1.Max = (picInner.ScaleHeight - picOuter.ScaleHeight)
  HScroll1.Max = (picInner.ScaleWidth - picOuter.ScaleWidth)
  HScroll1.LargeChange = HScroll1.Max / 20
  VScroll1.LargeChange = VScroll1.Max / 20
  HScroll1.SmallChange = HScroll1.Max / 50
  VScroll1.SmallChange = VScroll1.Max / 50
End Sub

Private Sub HScroll1_Change()
  picInner.Left = -HScroll1.Value
End Sub

Private Sub HScroll1_Scroll()
  HScroll1_Change
End Sub

Private Sub VScroll1_Change()
  picInner.Top = -VScroll1.Value
End Sub

Private Sub VScroll1_Scroll()
  VScroll1_Change
End Sub
0
 
DeAnCommented:
oops, change the Form_Resize

Private Sub Form_Resize()
  picOuter.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
 
  If picInner.ScaleWidth > picOuter.ScaleWidth Then
    HScroll1.Move 0, picOuter.Height - (picOuter.Height - picOuter.ScaleHeight) - HScroll1.Height, picOuter.ScaleWidth - VScroll1.Width, HScroll1.Height
    HScroll1.Max = (picInner.ScaleWidth - picOuter.ScaleWidth)
    HScroll1.LargeChange = HScroll1.Max / 20
    HScroll1.SmallChange = HScroll1.Max / 50
    HScroll1.Visible = True
  Else
    HScroll1.Visible = False
  End If
   
  If picInner.ScaleWidth > picOuter.ScaleWidth Then
    VScroll1.Move picOuter.ScaleWidth - (picOuter.ScaleWidth - picOuter.ScaleWidth) - VScroll1.Width, 0, VScroll1.Width, picOuter.ScaleHeight
    VScroll1.Max = (picInner.ScaleHeight - picOuter.ScaleHeight)
    VScroll1.LargeChange = VScroll1.Max / 20
    VScroll1.SmallChange = VScroll1.Max / 50
    VScroll1.Visible = True
  Else
    VScroll1.Visible = False
  End If

End Sub

And make sure that picInner.AutoSize = True
0
 
DeAnCommented:
and put picInner and the scrollbars in picOuter   ;)

sorry... tired
0
 
CleanupPingCommented:
Ockwig:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
DanRollinsCommented:
Moderator, my recommended disposition is:

    Split points between: DocM and DeAn

DanRollins -- EE database cleanup volunteer
0
All Courses

From novice to tech pro — start learning today.