vb怎么实现在图片框拖动画圆的功能,松开鼠标结束画圆?
1个回答
展开全部
Dim sp As Shape, sx As Single, sy As Single
Private Sub Form_Load()
Set sp = Me.Controls.Add("VB.Shape", "shape1")
Set sp.Container = Picture1
sp.Shape = 3
sp.BorderColor = &H888888
sp.Visible = False
Picture1.AutoRedraw = True
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
sx = X
sy = Y
sp.Move X, Y, 0, 0
sp.Visible = True
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim sw As Single
If Button = 1 Then
sw = X - sx
If Y - sy > sw Then sw = Y - sy
sp.Width = sw
sp.Height = sw
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Picture1.Circle (sp.Width / 2 + sp.Left, sp.Height / 2 + sp.Top), sp.Width / 2, vbRed
sp.Visible = False
End If
End Sub
追问
调试了有一句错了
然后我改好了 谢谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询