PDA

Click to See Complete Forum and Search --> : Pictuer and Move problem


shaykan
Jun 17th, 2000, 07:19 PM
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

Jun 17th, 2000, 09:08 PM
Instead of using a Control, you can try moving the Picture with BitBlt or PaintPicture

shaykan
Jun 18th, 2000, 06:43 PM
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

Jun 19th, 2000, 02:28 AM
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.

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.

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.

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.