'Add A Horizontal Scroll bar to the bottom of the screen, and a Vertical Scoll bar
on the right hand edge. Add A Picture Control with its border style set to 0
Option Explicit
Private iFullFormHeigth As Integer
Private iFullFormWidth As Integer
Private oldvPos As Integer
Private oldhPos As Integer
Private Sub GetFullSize()
Dim MyControl As Control
Dim FullHtemp As Integer
Dim FullVtemp As Integer
FullHtemp = 0
FullVtemp = 0
For Each MyControl In Me.Controls
If MyControl.Top + MyControl.Height > FullVtemp Then FullVtemp = MyControl.Top + MyControl.Height
If MyControl.Left + MyControl.Width > FullHtemp Then FullHtemp = MyControl.Left + MyControl.Width
Next
iFullFormHeigth = FullVtemp + HScroll1.Height
iFullFormWidth = FullHtemp + VScroll1.Width
End Sub
Private Sub ScrollMe()
Dim MyControl As Control
'Moves each textbox and Control if the scrollbar is clicked
For Each MyControl In Me.Controls
If Not (TypeOf MyControl Is VScrollBar) And _
Not (TypeOf MyControl Is PictureBox) And _
Not (TypeOf MyControl Is HScrollBar) Then
MyControl.Top = MyControl.Top + oldvPos - VScroll1.Value
MyControl.Left = MyControl.Left + oldhPos - HScroll1.Value
End If
Next
oldvPos = VScroll1.Value
oldhPos = HScroll1.Value
End Sub
Private Sub Form_Resize()
VScroll1.Left = Me.Width - (1.45 * VScroll1.Width)
HScroll1.Top = Me.Height - (2.45 * HScroll1.Height)
Picture1.Left = VScroll1.Left
Picture1.Top = HScroll1.Top
'If the full screen is already showing,
'then disable the scrollbar
VScroll1.Enabled = (iFullFormHeigth - Me.Height) >= 0
'First, make sure we aren't minimized
If Me.ScaleHeight > HScroll1.Height And Me.Width > VScroll1.Width Then
'If there is any more screen to see,
'modify the scrollbar
If VScroll1.Enabled Then
With VScroll1
.Height = Me.ScaleHeight - HScroll1.Height
.Min = 0
.Max = iFullFormHeigth - Me.Height
.SmallChange = Screen.TwipsPerPixelY * 10
.LargeChange = Me.ScaleHeight - HScroll1.Height
End With
'Otherwise, just resize the scrollbar for neatness
Else
VScroll1.Height = Me.ScaleHeight - HScroll1.Height
End If
HScroll1.Enabled = (iFullFormWidth - Me.Width) >= 0
If HScroll1.Enabled Then
With HScroll1
.Width = Me.ScaleWidth - VScroll1.Width
.Min = 0
.Max = iFullFormWidth - Me.Width
.SmallChange = Screen.TwipsPerPixelX * 10
.LargeChange = Me.ScaleWidth - VScroll1.Width
End With
Else
HScroll1.Width = Me.ScaleWidth - VScroll1.Width
End If
End If
End Sub
Private Sub Form_Load()
GetFullSize
Form_Resize
End Sub
Private Sub HScroll1_Change()
Call ScrollMe
End Sub
Private Sub HScroll1_Scroll()
Call ScrollMe
End Sub
Private Sub VScroll1_Change()
Call ScrollMe
End Sub
Private Sub VScroll1_Scroll()
Call ScrollMe
End Sub