vb让picturebox里面的图片移动,讲一下原理,不需要代码,还有loadpicture怎么总是提示不存在图片?
1个回答
展开全部
'最简单的方法是在图片框中套图片框。其它可以用PaintPicture来重绘,但没有前面方法有效。
'下面例子是:Picture1作相框,Picture2作相片。Picture2.autoSize设置为true
Dim onMoving As Boolean
Dim oldX As Single
Dim oldY As Single
Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
onMoving = True
oldX = X
oldY = Y
End If
End Sub
Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If onMoving Then
Picture2.Move X - oldX + Picture2.Left, Y - oldY + Picture2.Top
End If
End Sub
Private Sub Picture2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
onMoving = False
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询