Hi guys!
I'm trying to move a picture using BitBlt to avoid flickering.

I have got the picture to move both to the left and to the right, but when it moves to the right, it leaves some kind of trail....why is that???

Also, how can make a picture transparent...meaning how do i only show, ie. if the picture is a ball, the ball and not the background??

Source:

VB Code:
  1. Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
  2. Dim x As Integer
  3.  
  4. Private Sub Timer1_Timer()
  5. If GetAsyncKeyState(vbKeyRight) Then
  6.     GoRight
  7. End If
  8. If GetAsyncKeyState(vbKeyLeft) Then
  9.     GoLeft
  10. End If
  11.  
  12. End Sub
  13.  
  14. Public Sub GoRight()
  15. x = x + 2
  16.     Call BitBlt(Picture1.hDC, x, 0, Picture2.ScaleWidth \ Screen.TwipsPerPixelX, _
  17.     Picture2.ScaleHeight \ Screen.TwipsPerPixelY, _
  18.     Picture2.hDC, 0, 0, SRCcopy)
  19.     Picture1.Refresh
  20.      
  21.    
  22. End Sub
  23.  
  24. Public Sub GoLeft()
  25. x = x - 2
  26.     Call BitBlt(Picture1.hDC, x, 0, Picture2.ScaleWidth \ Screen.TwipsPerPixelX, _
  27.     Picture2.ScaleHeight \ Screen.TwipsPerPixelY, _
  28.     Picture2.hDC, 0, 0, SRCcopy)
  29.     Picture1.Refresh
  30.  
  31. End Sub

Module:

VB Code:
  1. ' ********************************************************************
  2. ' Project       :   BitBltPrimer.vbp
  3. ' Filename      :   BitBlt.bas
  4. ' Description   :   BitBlt API primer tutorial project
  5. ' Created       :   11.15 PM GMT + 10.00, February 23, 1998
  6. ' Modified      :   12:26 AM GMT + 10.00, October 17, 1998
  7. ' ********************************************************************
  8. ' Author        :   Michael Lambino
  9. ' E-mail        :   [email][email protected][/email]
  10. ' Comments      :   Copyright ©, 23 February, 1998, Michael Lambino
  11. ' License       :   Freeware - Freely distributable unmodified.
  12. '               :   No costs may be charged whatsoever for the
  13. '               :   distribution of this tutorial, in any form of
  14. '               :   media, without expressed permission of the author.
  15. ' ********************************************************************
  16.  
  17. ' Require all variables be declared.
  18.     Option Explicit
  19.  
  20. ' Enumerated raster operation constants
  21.     Public Enum RasterOps
  22.         '
  23.         ' Copies the source bitmap to destination bitmap
  24.         SRCcopy = &HCC0020
  25.         '
  26.         ' Combines pixels of the destination with source bitmap using
  27.         ' the Boolean AND operator.
  28.         SRCAND = &H8800C6
  29.         '
  30.         ' Combines pixels of the destination with source bitmap using
  31.         ' the Boolean XOR operator.
  32.         SRCinvert = &H660046
  33.         '
  34.         ' Combines pixels of the destination with source bitmap using
  35.         ' the Boolean OR operator.
  36.         SRCpaint = &HEE0086
  37.         '
  38.         ' Inverts the destination bitmap and then combines the results
  39.         ' with the source bitmap using the Boolean AND operator.
  40.         SRCERASE = &H4400328
  41.         '
  42.         ' Turns all output white.
  43.         WHITENESS = &HFF0062
  44.         '
  45.         ' Turn output black.
  46.         BLACKNESS = &H42
  47.     End Enum
  48.  
  49. ' BitBlt API Public Declaration
  50.     Declare Function BitBlt Lib "gdi32" ( _
  51.         ByVal hDestDC As Long, _
  52.         ByVal x As Long, _
  53.         ByVal y As Long, _
  54.         ByVal nWidth As Long, _
  55.         ByVal nHeight As Long, _
  56.         ByVal hSrcDC As Long, _
  57.         ByVal xSrc As Long, _
  58.         ByVal ySrc As Long, _
  59.         ByVal dwRop As RasterOps _
  60.         ) As Long
  61.  
  62.  
  63. ' ********************************************************************
  64. ' Parameter descriptions
  65. ' ********************************************************************
  66. ' ByVal hDestDC As Long :   hDC of object (Destination PictureBox hDC)
  67. '                       :   in which resulting Blt operation will
  68. '                       :   performed.
  69. ' ----------------------+---------------------------------------------
  70. ' ByVal x As Long       :   Leftmost coordinate (upper-left) of the
  71. '                       :   destination rectangle.
  72. ' ----------------------+---------------------------------------------
  73. ' ByVal y As Long       :   Topmost coordinate (upper-left) of the
  74. '                       :   destination rectangle.
  75. ' ----------------------+---------------------------------------------
  76. ' ByVal nWidth As Long  :   Width of the rectangle of the destination
  77. '                       :   image to be bltted.
  78. ' ----------------------+---------------------------------------------
  79. ' ByVal nHeight As Long :   height of the rectangle of the destination
  80. '                       :   image to be bltted.
  81. ' ----------------------+---------------------------------------------
  82. ' ByVal hSrcDC As Long  :   hDC of object (Source PictureBox hDC) in
  83. '                       :   which resulting Blt operation will be
  84. '                       :   performed from.
  85. ' ----------------------+---------------------------------------------
  86. ' ByVal xSrc As Long    :   Leftmost coordinate (upper-left) of the
  87. '                       :   source rectangle.
  88. ' ----------------------+---------------------------------------------
  89. ' ByVal ySrc As Long    :   Topmost coordinate (upper-left) of the
  90. '                       :   source rectangle.
  91. ' ----------------------+---------------------------------------------
  92. ' ByVal dwRop As Long   :   specifies the raster operation to be
  93. '                       :   performed as above.
  94. ' --------------------------------------------------------------------