PDA

Click to See Complete Forum and Search --> : Dragging a picture box while seeing its content.


Lior
Jan 20th, 2000, 04:48 AM
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..!

jjr459
Sep 4th, 2001, 11:48 PM
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

Zaei
Sep 5th, 2001, 05:53 AM
It is probably better to store OldX and OldY as static variables inside of the MouseMove event. Keeps global variables down.

Z.

Devion
Sep 5th, 2001, 06:12 AM
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 =)

Zaei
Sep 5th, 2001, 07:51 AM
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:

Type POINTAPI
X as Long
Y as Long
End Type

And store the values in that, so you dont take up a global variable name.

Z.

Devion
Sep 5th, 2001, 07:54 AM
Mmm.. yeah.. ok :), effiency to tha max :D