Results 1 to 2 of 2

Thread: How can I apply Scroll Bars to a Form Object.

  1. #1

    Thread Starter
    New Member
    Join Date
    May 1999
    Location
    Karachi, Pakistan
    Posts
    5

    Post

    Can anyone help me in doing so....

    Thanks in advance.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Place 2 Pictureboxes on a Form and a Horizontal and Vertical Scrollbar, (Don't Worry about positioning anything)

    Then, treating Picture1 as your Virtual Form, make it as big as you want your VF to be and add some controls to it so that they are contained within Picture1. (Right Click the Control, select Cut, Right Click Picture1, Select Paste).

    Then use this code in the Form..
    Code:
    Private Sub Form_Load()
        Picture1.Move 0, 0
        Picture1.BorderStyle = vbBSNone
        Picture1.ZOrder 1
        Picture2.BorderStyle = vbBSNone
        Picture2.Visible = False
    End Sub
    
    Private Sub Form_Resize()
        DoEvents
        HScroll1.Visible = (ScaleWidth < Picture1.Width)
        VScroll1.Visible = (ScaleHeight < Picture1.Height)
            
        If HScroll1.Visible Then
            HScroll1.Move 0, ScaleHeight - HScroll1.Height, ScaleWidth - IIf(VScroll1.Visible, VScroll1.Width, 0), HScroll1.Height
            HScroll1.Max = Picture1.Width - (ScaleWidth - IIf(VScroll1.Visible, VScroll1.Width, 0))
            HScroll1.LargeChange = HScroll1.Max / 10
            HScroll1.SmallChange = 100
        Else
            HScroll1 = 0
        End If
        If VScroll1.Visible Then
            VScroll1.Move ScaleWidth - VScroll1.Width, 0, VScroll1.Width, ScaleHeight - IIf(HScroll1.Visible, HScroll1.Height, 0)
            VScroll1.Max = Picture1.Height - (ScaleHeight - IIf(VScroll1.Visible, HScroll1.Height, 0))
            VScroll1.LargeChange = VScroll1.Max / 10
            VScroll1.SmallChange = 100
        Else
            VScroll1 = 0
        End If
        If HScroll1.Visible And VScroll1.Visible Then
            Picture2.Move VScroll1.Left, HScroll1.Top, VScroll1.Width, HScroll1.Height
            Picture2.Visible = True
        Else
            Picture2.Visible = False
        End If
    End Sub
    
    Private Sub HScroll1_Change()
        HScroll1_Scroll
    End Sub
    
    Private Sub HScroll1_Scroll()
        Picture1.Move -HScroll1, -VScroll1
    End Sub
    
    Private Sub VScroll1_Change()
        HScroll1_Scroll
    End Sub
    
    Private Sub VScroll1_Scroll()
        HScroll1_Scroll
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width