' Arrange the scroll bars.
Private Sub ArrangeControls()
Dim border_width As Single
Dim got_wid As Single
Dim got_hgt As Single
Dim need_wid As Single
Dim need_hgt As Single
Dim need_hbar As Boolean
Dim need_vbar As Boolean
' See how much room we have and need.
border_width = picOuter.Width - picOuter.ScaleWidth
got_wid = picContainer.ScaleWidth - border_width
got_hgt = picContainer.ScaleHeight - border_width
need_wid = picInner.Width
need_hgt = picInner.Height
' See if we need the horizontal scroll bar.
If need_wid > got_wid Then
need_hbar = True
got_hgt = got_hgt - hbarMarble.Height
End If
' See if we need the vertical scroll bar.
If need_hgt > got_hgt Then
need_vbar = True
got_wid = got_wid - vbarMarble.Width
' See if we now need the horizontal scroll bar.
If (Not need_hbar) And need_wid > got_wid Then
need_hbar = True
got_hgt = got_hgt - hbarMarble.Height
End If
End If
' Arrange the controls.
picOuter.Move 0, 0, got_wid + border_width, got_hgt + _
border_width
If need_hbar Then
hbarMarble.Move 0, got_hgt + border_width, got_wid _
+ border_width
hbarMarble.Min = 0
hbarMarble.Max = picInner.ScaleWidth - got_wid
hbarMarble.SmallChange = got_wid / 5
hbarMarble.LargeChange = got_wid
hbarMarble.Visible = True
Else
hbarMarble.Value = 0
hbarMarble.Visible = False
End If
If need_vbar Then
vbarMarble.Move got_wid + border_width, 0, _
vbarMarble.Width, got_hgt + border_width
vbarMarble.Min = 0
vbarMarble.Max = picInner.ScaleHeight - got_hgt
vbarMarble.SmallChange = got_hgt / 5
vbarMarble.LargeChange = got_hgt
vbarMarble.Visible = True
Else
vbarMarble.Value = 0
vbarMarble.Visible = False
End If
End Sub
|