vb picturebox 图形拖动

来源:百度知道 编辑:UC知道 时间:2024/05/06 12:14:37
如图 想要实现将picture1中力F拖动到picture2 中的梁上 两个图形都是用picture属性加载的 请高手们赐教...最好能帮我把程序写出来啊 谢谢啦

用下面的代码可以把Picture1拖到任意位置:

Dim xx As Single, yy As Single

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xx = X: yy = Y
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Picture1.Move Picture1.Left + X - xx, Picture1.Top + Y - yy
End Sub