PDA

Click to See Complete Forum and Search --> : bitmap dragging


Tonio169
Nov 17th, 1999, 09:48 AM
how can i drag a blit'd bitmap around a form?

Aaron Young
Nov 18th, 1999, 12:18 AM
Move the PictureboxControl you BitBlt'd the Image onto, eg.

Private oX As Single
Private oY As Single

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
oX = X
oY = Y
End If
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static lX As Single
Static lY As Single
If Button = vbLeftButton And (lX <> Y Or lY <> Y) Then
Picture1.Move Picture1.Left + X - oX, Picture1.Top + Y - oY
lX = X
lY = Y
End If
End Sub


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

Tonio169
Nov 18th, 1999, 09:36 AM
let me make my question more specific...
the picture is blit'd on the form.

Aaron Young
Nov 18th, 1999, 01:46 PM
I would suggest adding a Picturebox to the Form and BitBlt'ing the Image into the Picturebox, so you can use the Code I posted.
Otherwise you'll have to check the Coords of the Mouse to see if it's in the Area of the Image, then Clear and Redraw the Image in its New Location as the User Drags the Mouse.
Most Likely resulting in a bad Flickering effect.


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net