Results 1 to 4 of 4

Thread: Pictuer and Move problem

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2000
    Posts
    45

    Question

    Hi
    I have picture on my form as background.
    And I have anther image that spouse to move on the form.
    (The other image is a gif with out a background)
    I am using the “Move” function with “For” loop
    My problem is:
    1. When I am using the PictureBox control the image does not blink but I can’t see the form background.
    (Is there transfer possibility?)
    2. When I am using the Image control I can see the form background but the image control blink so the pictures blink too.
    3. When I am using the AniGif control I have the same problem I can see the form background but the image control blink so the picture blink too.

    Is there any option to fix this thing?

    Thanks

    Shaykan
    VBmaster

  2. #2
    Guest
    Instead of using a Control, you can try moving the Picture with BitBlt or PaintPicture

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2000
    Posts
    45

    Question More Help

    Hi
    Can you pleas send me a small code sample of BitBlt or PaintPicture.
    It will help me allot.
    Again just to mention I have a picture on the form and I need that the small image
    will move on the form

    Visual Basic 6.0 SP3

    Thanks
    VBmaster

  4. #4
    Guest
    First, I'll start out with an example of PaintPicture. Before you use the Code, make sure there is an ImageBox and a Timer on the Form.

    Insert this code into the Timer.
    Code:
    Private Sub Timer1_Timer()
    
        ' Clear the screen
        Cls           
        Static X, Y
        ' Add 10 to each variable
        X = X + 10   
        Y = Y + 10
        ' Paint the Image on the Form.
        PaintPicture Image1.Picture, X, Y, Image1.Width, Image1.Height
    
    End Sub
    Now we will move on to BitBlt. What you need is a Form with a 2 PictureBox's and a Timer.

    Code for module.
    Code:
    Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (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
    Now, you must create the Images for each PictureBox. 1 Image will be you original image and the other will be your Mask. A mask is exactly the same as your image, but the background is coloured white and your image is all black.

    Now put this code in your Timer.
    Code:
    Private Sub Timer1_Timer()
    
        Cls
        Static x, y
        x = x + 10
        y = y + 10
        ' First lay on the mask. 
        BitBlt Form1.hDC, x, y, picMask.Width, picMask.Height, picMask.hDC, 0, 0, SRCAND
        ' Now lay on the picture.
        BitBlt Form1.hDC, x, y, Picture1.Width, Picture1.Height, Picture1.hDC, 0, 0, SRCPAINT
        
    
    End Sub
    Hope this helps.

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