刚刚看到有发表再创提上移动控件的贴子,看了看,就是觉得代码长。不过功能到挺全面,支持键盘移动!
本人收藏了一个范例,虽然只支持鼠标拖动,但是代码少少,有兴趣不妨看看
示例源码:
Private Sub 图像1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If 图像1.Left - cX + X > 0 Then
图像1.Left = 图像1.Left - cX + X
End If
If 图像1.Top - cY + Y > 0 And 图像1.Top - cY + Y + 图像1.Height < 主体.Height Then
图像1.Top = 图像1.Top - cY + Y
End If
End If
标签2.Caption = "Left:" & 图像1.Left - cX + X
标签3.Caption = "Top:" & 图像1.Top - cY + Y
End Sub