[RESOLVED] Drag/Drop picture boxes
I'll set the scene first :P
I have one big picture box with multiple smaller ones inside the big one.
Is it possible to use the drag/drop function to drag the little one around inside the big one or is that only used for transferring from one picture box to the other?
Re: Drag/Drop picture boxes
Make a control array of picture boxes named Picture2, try this....
Code:
Option Explicit
Private bPressed As Boolean
Private iX As Long
Private iY As Long
Private Sub Picture2_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Picture2(Index).ZOrder 0
bPressed = True
iX = X
iY = Y
End If
End Sub
Private Sub Picture2_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If bPressed = True Then
Picture2(Index).Left = Picture2(Index).Left + X - iX
Picture2(Index).Top = Picture2(Index).Top + Y - iY
End If
End Sub
Private Sub Picture2_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
bPressed = False
End Sub
Edit Note: The scalemode of picture2 must be set to the same scalemode of their container.
Re: Drag/Drop picture boxes
Thanks a ton, code works great.
Saved me a bit of time too. I had a go last night but just couldn't get the maths right - it leaps out at you when you see it done though!
I think that's a chunk of code which is going in my code bank :)