'Form1 Option ExplicitPublic dx As Single Public dy As SinglePrivate Sub Form_Load() Form2.Show End SubPrivate Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbLeftButton Then dx = X dy = Y Image1.Drag vbBeginDrag Set Image1.DragIcon = Image1.Picture End If End Sub 'Form2 Option ExplicitPrivate Sub Form_DragDrop(Source As Control, X As Single, Y As Single) If Source Is Form1.Image1 Then Set Image1.Picture = Form1.Image1.Picture Image1.Move X - Form1.dx, Y - Form1.dy Image1.Visible = True Form1.Image1.Visible = False End If End SubPrivate Sub Form_Load() Image1.Visible = False End Sub
Option ExplicitPublic dx As Single
Public dy As SinglePrivate Sub Form_Load()
Form2.Show
End SubPrivate Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
dx = X
dy = Y
Image1.Drag vbBeginDrag
Set Image1.DragIcon = Image1.Picture
End If
End Sub
'Form2
Option ExplicitPrivate Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
If Source Is Form1.Image1 Then
Set Image1.Picture = Form1.Image1.Picture
Image1.Move X - Form1.dx, Y - Form1.dy
Image1.Visible = True
Form1.Image1.Visible = False
End If
End SubPrivate Sub Form_Load()
Image1.Visible = False
End Sub
我也曾经这样试过,但是只能支持Icon图标,图片就不行了。