PDA

Click to See Complete Forum and Search --> : Moving Images With The Mouse


SteveCRM
Nov 4th, 1999, 06:17 AM
To move a picture with the mouse I used the Code: Image1.Left = X But while going right it is really choppy, but going left it is fine. What's wrong, should I use a different method?

:)

Steve

Aaron Young
Nov 4th, 1999, 08:41 AM
Use a Picturebox it'll yield better results, eg.

Private oX As Integer
Private oY As Integer

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
oX = ScaleX(X, ScaleMode, vbPixels)
oY = ScaleY(Y, ScaleMode, vbPixels)
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 lX = X And lY = Y Then Exit Sub
lX = X
lY = Y
If Button = vbLeftButton Then
X = X - ScaleX(oX, vbPixels, ScaleMode)
Y = Y - ScaleY(oY, vbPixels, ScaleMode)
Picture1.Move X + Picture1.Left, Y + Picture1.Top
End If
End Sub

Just Click on the Picture and Drag...

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