Option Explicit
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Martin Liss has no warranty,
' obligations or liability for any Sample Application Files.
Private Sub Form_Activate()
' So that scrooling will happen if the user immediately presses
' PageUp or PageDown
picPicture.SetFocus
End Sub
Private Sub Form_Load()
HScroll1.Width = picWindow.Width
' HScroll1.Max = picPicture.Width - picWindow.Width
HScroll1.SmallChange = 200
HScroll1.LargeChange = picWindow.Width
If picPicture.Picture = 0 Then
lblNoPicture.Visible = True
lblNoPicture.Caption = "Change picPicture's Picture property to refer " _
& "to the location of winnt.bmp (or any large picture)"
End If
End Sub
Public Sub CheckKeyCode(KeyCode As Integer)
'***************************************************************************
'Purpose: Intercept and act on special keys on me so
' that up and down arrows and scroll bar works as expected. Also
' automatically scroll screen when Tab key would otherwise disappear
' off the screen.
'Inputs: KeyCode - The ASCII(?) value of the key pressed
'Outputs: None
'***************************************************************************
Dim nScrollValue As Double
Dim nOnePage As Integer
nOnePage = Me.VScroll1.Height
If KeyCode = vbKeyPageUp Or KeyCode = vbKeyPageDown Then
If KeyCode = vbKeyPageDown Then
nScrollValue = -Me.picPicture.Top + nOnePage
Else
nScrollValue = -Me.picPicture.Top - nOnePage
End If
'Make sure that the scroll bar 'handle' is not attempted to be positioned
'below the bottom of the scroll bar.
If nScrollValue > Me.VScroll1.Max Then
nScrollValue = Me.VScroll1.Max
Me.picPicture.Top = -Me.VScroll1.Max
End If
If nScrollValue > 0 Then
Me.VScroll1.Value = nScrollValue
Else
Me.VScroll1.Value = 0
End If
End If
End Sub
Private Sub HScroll1_Change()
picPicture.Left = -(HScroll1.Value)
End Sub
Private Sub picPicture_KeyDown(KeyCode As Integer, Shift As Integer)
CheckKeyCode KeyCode
End Sub
Private Sub ExitButton_Click()
Unload Me
End Sub