Results 1 to 2 of 2

Thread: Scrolling Forms/ Using Frames to scroll

  1. #1

    Thread Starter
    Lively Member flint's Avatar
    Join Date
    Oct 2000
    Posts
    67

    Cool

    After searching the the world over I found a lead here at VB-World on how to create scrolling forms. I know that the code is slightly inefficient but it gets the job done.

    Insert this code onto the form module:
    Code:
    Dim intLastPoz As Integer
    
    Public Sub ScrollForm()
    
    Dim ctl As Control
    
    'Use carriage returns as needed here.
    'Type NOSCROLL in the .Tag property of the control to keep 
    'the control from scrolling.
        For Each ctl In frm3.Controls
    If ctl.Tag <> "NOSCROLL" And Not (TypeOf ctl Is VScrollBar) _ 
      And Not (TypeOf ctl Is Timer) Then _
      ctl.Top = ctl.Top + intLastPoz - VScroll1.Value
        Next ctl  
    'to create a horizontally scrolling form use .Left instead
    'of .Top in the above loop.
    
    intLastPoz = VScroll1.Value
    
    End Sub
    
    
    Private Sub VScroll1_Change()
        ScrollForm
    End Sub
    
    
    Private Sub VScroll1_Scroll()
        ScrollForm
    End Sub
    This code goes in Form_load
    Code:
    Dim intFullHeight As Integer
    Dim intDisplayHeight As Integer
    
        'Change these as needed
        intFullHeight = 9000
        intDisplayHeight = 5040
        
        frm3.Height = intDisplayHeight
    
        With VScroll1  'name of the vertical scrollbar
            .Height = frm3.ScaleHeight
            .Min = 0
            .Max = intFullHeight - intDisplayHeight
    'change the 10 to a larger number to create a faster scroll
            .SmallChange = Screen.TwipsPerPixelX * 10 
            .LargeChange = .SmallChange
        End With
    I found out from trial and error that ScrollForm loop will not scroll a timer control so I added on to the code that I found here (I believe by Karl Moore).

    When I scroll the controls on the form disappear under the form's title bar. Is there a way to make the controls disappear under the columns titles (like the freezeframe in excel)? I suspect that I could use a borderless frame to scroll a specific area on the form. Would anyone care to share the How-To on creating a scrolling frame?

    Flint
    A person who walks in another's tracks leaves no footsteps.

  2. #2

    Thread Starter
    Lively Member flint's Avatar
    Join Date
    Oct 2000
    Posts
    67
    Can I create a smooth scrolling for this feature? Any suggestions? My controls are kind of jumpy when I scroll just looking for a fix. Share the knowledge or opinions if you have any.

    Flint

    [Edited by flint on 10-16-2000 at 05:02 PM]

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