This could be a starting point for your experiments:
|
Jabaco Source
|
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
33
34
|
Option Explicit
Private bDragging As Boolean
Private dx As Integer
Private dy As Integer
Private lastX As Integer
Private lastY As Integer
Public Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not bDragging Then
bDragging = True
dx = Picture1.Left - X
dy = Picture1.Top - Y
End If
End Sub
Public Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If bDragging Then
If (X - lastX) ^ 2 + (Y - lastY) ^2 > 10 Then
Picture1.Left = X + dx
Picture1.Top = Y + dy
lastX = X
lastY = Y
End If
End If
End Sub
Public Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
bDragging = False
End Sub
Public Sub Form_Load()
bDragging = False
End Sub
|
Strangely enough, the dragged pictureBox is not fully in sync with the mouse cursor.
There might be a problem with the coordinate scaling.
Happy trying!
A1880