画图怎样处理鼠标,鼠标不能越界
本帖最后由 bcrun 于 2012-08-29 10:01:24 编辑 比如在picturebox上画图形,如果鼠标超过picturebox的范围,但是画得图不能出去,怎么处理?
Dim x1, y1 As Long
Private Sub Command1_Click()
Picture1.Cls
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button Then
x1 = x: y1 = y
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button Then
Picture1.DrawWidth = 3
Picture1.Cls
Picture1.Circle (x1, y1), Sqr((x1 - x) ^ 2 + (y1 - y) ^ 2)
End If
End Sub