Results 1 to 3 of 3

Thread: How can I scroll using a picturebox

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Location
    Dayton, Ohio
    Posts
    1
    Hi,

    I am dynamically loading a control array of textboxes into a picturebox. My problem is when I start to scroll down I loose the subsequent textboxes that aren't visible before you have to start scrolling. Any ideas???

    Thanks in advance!

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    are you resizing the picture box as you add controls?

    here's a VERY rough example

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    Dim i As Integer
    For i = 1 To 10
      Load Text1(i)
      Text1(i).Top = Text1(i - 1).Top + 460
      Text1(i).Visible = True
      Picture1.Height = Picture1.Height + 460
    Next i
    VScroll1.Max = Picture1.Height
    
    End Sub
    
    Private Sub VScroll1_Scroll()
    Picture1.Top = -VScroll1.Value
    End Sub
    Mark
    -------------------

  3. #3
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Try this on for size...

    I think I got this here somewhere...wish I could give credit to the author...

    Code:
    'Place a Timer on the Form and a Label inside a Picturebox Control....
    Private Sub Form_Load()
        Label1 = "Scrolly Thing.." & vbCrLf & vbCrLf & _
        "Line1" & vbCrLf & _
        "Line2" & vbCrLf & _
        "Line3" & vbCrLf & _
        "Line4"
        Timer1.Interval = 100
    End Sub
    Private Sub Timer1_Timer()
        Static sLastTag As String
        Static YPos As Long
        
        If Label1 <> sLastTag Then
            Label1.AutoSize = True
            sLastTag = Label1
            Picture1.ScaleMode = vbPixels
            YPos = Picture1.ScaleHeight
            Label1.Left = (Picture1.ScaleWidth - Label1.Width) / 2
        End If
        
        If YPos > -Picture1.TextHeight(sLastTag) Then
            YPos = YPos - 3
        Else
            YPos = Picture1.ScaleHeight
        End If
        
        Label1.Top = YPos
    End Sub
    ~seaweed

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