窗体上放置一图片框,通过鼠标在图片框内的拖动画红色的实心圆
窗体上放置一图片框,通过鼠标在图片框内的拖动画红色的实心圆。鼠标左键按下点为圆心,鼠标左键释放点到鼠标按下点所拖动的距离为半径。当按下鼠标右键时,清除图片框上的图形。...
窗体上放置一图片框,通过鼠标在图片框内的拖动画红色的实心圆。鼠标左键按下点为圆心,鼠标左键释放点到鼠标按下点所拖动的距离为半径。当按下鼠标右键时,清除图片框上的图形。
展开
1个回答
展开全部
Dim cx As Integer
Dim cy As Integer
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
cx = X
cy = Y
PSet (X, Y)
End If
If Button = 2 Then
Picture1.Cls
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
r = Sqr((X - cx) ^ 2 + (Y - cy) ^ 2)
Picture1.FillStyle = 0
Picture1.FillColor = vbRed
Picture1.Circle (cx, cy), r
End If
End Sub
Dim cy As Integer
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
cx = X
cy = Y
PSet (X, Y)
End If
If Button = 2 Then
Picture1.Cls
End If
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
r = Sqr((X - cx) ^ 2 + (Y - cy) ^ 2)
Picture1.FillStyle = 0
Picture1.FillColor = vbRed
Picture1.Circle (cx, cy), r
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询