我想做一个画动态圆的小程序,但遇到一点问题,请各位大虾帮忙看一下.
要求:1.鼠标左键按下确定圆心,拖动显示虚线圆,鼠标抬起完成画圆
2.画下一个圆的时候,上一个圆仍然存在
程序如下:
Dim X0 As Single, Y0 As Single, R As Single
Dim IsDown As Boolean
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
X0 = X
Y0 = Y
IsDown = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If IsDown = True Then
DrawStyle = 2
R = ((X - X0) ^ 2 + (Y - Y0) ^ 2) ^ 0.5
Cls
Circle (X0, Y0), R
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
IsDown = False
DrawStyle = 0
Cls
Circle (X0, Y0), R
End Sub
问题:以上程序虽然能实现"要求1",但是每当画下一个圆的时候,上一个画的圆都被清除掉了,"要求2"实现不了.
我自己觉得应该是Cls语句用的不对,但我又找不出其他的替代方法,请高手帮忙改一下.