VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form frmScroll 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Two Flex Grids"
   ClientHeight    =   6015
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   8940
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6015
   ScaleWidth      =   8940
   StartUpPosition =   2  'CenterScreen
   Begin VB.VScrollBar VScroll1 
      Height          =   6015
      Left            =   8580
      TabIndex        =   2
      Top             =   0
      Width           =   375
   End
   Begin VB.PictureBox picWindow 
      BorderStyle     =   0  'None
      Height          =   6015
      Left            =   0
      ScaleHeight     =   6015
      ScaleWidth      =   8535
      TabIndex        =   0
      Top             =   0
      Width           =   8535
      Begin VB.PictureBox picI_Scroll 
         BorderStyle     =   0  'None
         Height          =   13000
         Left            =   0
         ScaleHeight     =   13005
         ScaleWidth      =   8535
         TabIndex        =   1
         Top             =   0
         Width           =   8535
         Begin MSFlexGridLib.MSFlexGrid MSFlexGrid2 
            Height          =   3495
            Left            =   1440
            TabIndex        =   5
            Top             =   3840
            Width           =   6375
            _ExtentX        =   11245
            _ExtentY        =   6165
            _Version        =   393216
            Cols            =   3
            BorderStyle     =   0
         End
         Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
            Height          =   3495
            Left            =   1440
            TabIndex        =   4
            Top             =   360
            Width           =   6375
            _ExtentX        =   11245
            _ExtentY        =   6165
            _Version        =   393216
            BorderStyle     =   0
         End
         Begin VB.CommandButton cmdExit 
            Caption         =   "&Exit"
            Height          =   375
            Left            =   3863
            TabIndex        =   3
            Top             =   12480
            Width           =   1215
         End
      End
   End
End
Attribute VB_Name = "frmScroll"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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.


' All objects that should scroll must be drawn in picI_Scroll

' If you need to edit any of the objects that are below the bottom of the form,
' temporarily change picI_Scroll.Top to -1000, -10000, or whatever it takes
' (It will take -11000 to see the exit button)


Private Sub cmdExit_Click()

    Unload Me
    Set frmScroll = Nothing
    
End Sub

Private Sub Form_Activate()

    ' So that scrooling will happen if the user immediately presses
    ' PageUp or PageDown
    picI_Scroll.SetFocus
    
End Sub

Private Sub Form_Load()

    Dim intIndex As Integer
    
    picWindow.Left = 0
    picWindow.Width = Me.Width - VScroll1.Width
    
    VScroll1.Height = picWindow.Height
    VScroll1.Max = picI_Scroll.Height - picWindow.Height
    VScroll1.SmallChange = 100
    VScroll1.LargeChange = picWindow.Height
    VScroll1.Left = Me.Width - VScroll1.Width - 60
    VScroll1.Top = 0
    
    picI_Scroll.Left = 0
    picI_Scroll.Width = picWindow.Width
    
    ' Flexgrid stuff
    MSFlexGrid1.ScrollBars = flexScrollBarNone
    MSFlexGrid2.ScrollBars = flexScrollBarNone
    MSFlexGrid1.Height = MSFlexGrid1.RowHeight(0) * MSFlexGrid1.Rows
    MSFlexGrid2.Height = MSFlexGrid2.RowHeight(0) * MSFlexGrid2.Rows
    MSFlexGrid2.Top = MSFlexGrid1.Top + MSFlexGrid1.Height
    For intIndex = 0 To 20
        If intIndex >= 2 Then
            MSFlexGrid1.Rows = intIndex + 1
            MSFlexGrid1.Height = MSFlexGrid1.Height + MSFlexGrid1.RowHeight(0)
            MSFlexGrid2.Top = MSFlexGrid2.Top + MSFlexGrid1.RowHeight(0)
        End If
        MSFlexGrid1.TextMatrix(intIndex, 1) = intIndex
    Next
    For intIndex = 0 To 25
        If intIndex >= 2 Then
            MSFlexGrid2.Rows = intIndex + 1
            MSFlexGrid2.Height = MSFlexGrid2.Height + MSFlexGrid2.RowHeight(0)
        End If
        MSFlexGrid2.TextMatrix(intIndex, 2) = intIndex
    Next
    
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
'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.picI_Scroll.Top + nOnePage
        Else
            nScrollValue = -Me.picI_Scroll.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.picI_Scroll.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 picI_Scroll_KeyDown(KeyCode As Integer, Shift As Integer)

    CheckKeyCode KeyCode
    
End Sub

Private Sub VScroll1_Change()

    picI_Scroll.Top = -(VScroll1.Value)
    
    ' So that the scrollbar doesn't blink
    cmdExit.SetFocus

End Sub


