1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Option Explicit
Dim x0 As Integer, Y0 As Integer
Private Sub picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If Picture2.Left > 0 And (Picture2.Left + Picture2.ScaleWidth) < 2775 And Picture2.Top > 0 And (Picture2.Top + Picture2.ScaleHeight) < 2115 Then ' definition des limites de ma picturebox1
Picture2.Move Int((Picture2.Left + ScaleX(X, 1, 3)) - x0), Int((Picture2.Top + ScaleY(Y, 1, 3)) - Y0)
Else
If Picture2.Left <= 0 Then
Picture2.Left = 1
End If
If (Picture2.Left + Picture2.ScaleWidth) >= 2775 Then
Picture2.Left = 2770 - Picture2.ScaleWidth
End If
If Picture2.Top <= 0 Then
Picture2.Top = 5
End If
If (Picture2.Top + Picture2.ScaleHeight) Then
Picture2.Top = 2110 - Picture2.ScaleWidth
End If
End If
End If
Label1.Caption = Picture2.Left
Label2.Caption = Picture2.Top
End Sub
Private Sub picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Y0 = ScaleY(Y, 1, 3)
x0 = ScaleX(X, 1, 3)
End If
End Sub |
Partager