Results 1 to 5 of 5

Thread: [RESOLVED] Why does the image do this?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Resolved [RESOLVED] Why does the image do this?

    Im trying to make the backgound scroll. But one of the images flashes! How can i fix this?
    Last edited by Gamemaster1494; Mar 25th, 2010 at 08:31 PM.

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Why does the image do this?

    Try using pic boxes instead, and instead of moving the objects paint the image to the area, something like this (file attached).

    Code:
    Option Explicit
    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    
    Private Sub Timer_Timer()
        Static ImgLeft As Long
        Picture2.Cls
        BitBlt Picture2.hDC, ImgLeft, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture1.hDC, 0, 0, vbSrcCopy
        BitBlt Picture2.hDC, Picture1.ScaleWidth + ImgLeft, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture1.hDC, 0, 0, vbSrcCopy
        Picture2.Refresh
        ImgLeft = ImgLeft - 4
        If ImgLeft <= -Picture1.ScaleWidth Then ImgLeft = 0
    End Sub
    
    Private Sub Form_Load()
        ' source
        Picture1.ScaleMode = vbPixels
        Picture1.AutoRedraw = True
        Picture1.Visible = False
        ' destination
        Picture2.ScaleMode = vbPixels
        Picture2.AutoRedraw = True
        Picture2.Move 0, 0, Picture1.Width, Picture1.Height
    End Sub
    Attached Files Attached Files
    Last edited by Edgemeal; Dec 10th, 2009 at 12:15 AM. Reason: added pic box settings

  3. #3
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Why does the image do this?

    Works great, Edge.

    Dumb question: where is your image stored/referenced?

    I'd like to steal this for a game I made for my kids, but can't figure out how to sub my background for yours! Probably obvious, but I'm only on my first cup of (bad) coffee this morning!

    Bryce

  4. #4
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Why does the image do this?

    Quote Originally Posted by vbfbryce View Post
    Works great, Edge.

    Dumb question: where is your image stored/referenced?

    I'd like to steal this for a game I made for my kids, but can't figure out how to sub my background for yours! Probably obvious, but I'm only on my first cup of (bad) coffee this morning!

    Bryce
    Picture1 holds the source image, you'll probably want to set the source to autoresize also, maybe something like,,.,
    Code:
     
    Private Sub Form_Load()
        ' source
        Picture1.ScaleMode = vbPixels
        Picture1.AutoRedraw = True    
        Picture1.AutoSize = True
        Picture1.Visible = False
        Set Picture1.Picture = LoadPicture("My_Image.bmp")
        ' destination
        Picture2.ScaleMode = vbPixels
        Picture2.AutoRedraw = True
        Picture2.Move 0, 0, Picture1.Width, Picture1.Height
    End Sub

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: Why does the image do this?

    Thank you! It worked!

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