Originally Posted by Cerian Knight
Not sure if it is your issue, but that method of moving the picture assumes the Form ScaleMode is Twips.
That isn't quite correct.
The code assumes the ScaleMode of the picturebox and the container are the same. They have to match, so could both be twips, or pixels, or points, etc...
I don't understand how the outline can move independent of the picture unless there was other code that used the MouseCapture (i.e. releaseCapture and sendMessage method) to move the window, and your options were to set to "show outline" when dragging.
But perhaps you're drawing the Outline in the container by some other method independent of the picturebox being moved.
Getting back to my original comment about the scalemode (or perhaps more correctly, the scale units) needing to be the same, your property windows indicate that the container picturebox's scalemode is "User" while the embedded picturebox's scalemode is "twips".
Perhaps that is the source of the failure (as I don't understand the complete situation, but that is one thing that is wrong regardless).
To have a more generic routine that should be able to convert relative motion in the child picturebox to relative motion of the container regardless of the scales in the two boxes, you need to use the ScaleX and ScaleY functions to convert between the scales.
An example where picture1 is inside picture2, and picture2's scale is arbitrarily set to a user scale with 0,0 in the middle and the width and height are around 200,200 regardless of the actual dimensions of the outer picture box.
The code should adapt the movement of the mouse in one scale to picturebox movement in the other arbitrary scale.
Private Sub Form_Load()
Picture2.Scale (-100, -100)-(100, 100)
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static lx As Single, ly As Single
Dim dx As Single, dy As Single
If Button = vbLeftButton Then 'or vbRightButton
dx = Picture2.ScaleX(X - lx, Picture1.ScaleMode, Picture2.ScaleMode)
dy = Picture2.ScaleY(Y - ly, Picture1.ScaleMode, Picture2.ScaleMode)
Picture1.Left = Picture1.Left + dx
Picture1.Top = Picture1.Top + dy
lx = X: ly = Y
Replace Picture2 with whatever your container's name is.
Again, I don't fully understand the problem so don't know if this will fix it, but it definitely is an issue in any case.