Hey all of you out there...
How do I drag a picture box so when i am dragging, i see the picture box's picture ?
------------------
------
God:
------
Oh...those israeli programmers..!
Printable View
Hey all of you out there...
How do I drag a picture box so when i am dragging, i see the picture box's picture ?
------------------
------
God:
------
Oh...those israeli programmers..!
The following code will work:
Dim oldX As integer
Dim oldY As Integer
Private Sub PiecePic_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
oldX = X
oldY = Y
End If
End Sub
Private Sub PiecePic_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
PiecePic(Index).Top = PiecePic(Index).Top + (Y - oldY)
PiecePic(Index).Left = PiecePic(Index).Left + (X - oldX)
End If
End Sub
It is probably better to store OldX and OldY as static variables inside of the MouseMove event. Keeps global variables down.
Z.
And how would you cope with the oldX and oldY vars then if they are inside the sub since they don't keep their value (or share it) with the other sub.
Looking at the that code thats the only simple way to do it =)
I dont know of any reason why you would want to use those values outside of that Sub. But, if you really wanted to share them with everyone, you could:
And store the values in that, so you dont take up a global variable name.Code:Type POINTAPI
X as Long
Y as Long
End Type
Z.
Mmm.. yeah.. ok :), effiency to tha max :D