Results 1 to 4 of 4

Thread: Scrolling background, exAmpLe included

  1. #1

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720

    Scrolling background, exAmpLe included

    I included my example, I want to scroll that graphic in the picbox, forever, I tried to make it like a pattern on the sides so it can scroll evenLy without anyone noticing but I don't care about the graphic, I just did it as a test, I want to know how to make it scroll across, and keep repeating.
    Attached Files Attached Files
    asdf

  2. #2

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720
    -_- bUMP -_0`
    asdf

  3. #3

    Thread Starter
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720
    I just need to know when the picturebox fully passed the left side of the form. then I can just move it to the right and repeat it. I have the equation for this at home somewhere but I am in school now. I need to check the "right" side of the picture box to see if it turns to -1 (passed form.left) But the code isn't coming to me~
    asdf

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Try something like this:
    VB Code:
    1. Option Explicit
    2.  
    3. Private oPic As IPictureDisp
    4. Private Const SCROLLSPEED As Long = 1
    5.  
    6. Private Sub Form_Load()
    7.   ' Use Pixels
    8.   ScaleMode = vbPixels
    9.   ' Store the Form Picture to be scrolled
    10.   Set oPic = Picture
    11.   ' Animation Speed
    12.   Timer1.Interval = 10
    13.   Timer1.Enabled = True
    14. End Sub
    15.  
    16. Private Sub Timer1_Timer()
    17.   Static lLeft As Long
    18.   Dim lWidth As Long, lHeight As Long
    19.   Dim lScrollSpeed As Long
    20.  
    21.   lWidth = ScaleX(oPic.Width, vbHimetric, vbPixels)
    22.   lHeight = ScaleY(oPic.Height, vbHimetric, vbPixels)
    23.  
    24.   ' Move Image to Left
    25.   lLeft = lLeft - SCROLLSPEED
    26.   ' If The Image is completely off screen, reset to Zero
    27.   If lLeft <= -lWidth Then lLeft = 0
    28.  
    29.   ' Draw the Image at it's Offset, then append a copy to the end
    30.   ' giving room to wrap the image as it's scrolled.
    31.   PaintPicture oPic, lLeft, 0, lWidth, lHeight, 0, 0, lWidth, lHeight
    32.   PaintPicture oPic, lLeft + lWidth, 0, lWidth, lHeight, 0, 0, lWidth, lHeight
    33. End Sub
    You should be able to easily adapt this to scroll inside a picturebox instead of the form.

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