画图怎样处理鼠标,鼠标不能越界
比如在picturebox上画图形,如果鼠标超过picturebox的范围,但是画得图不能出去,怎么处理?
Dim x1, y1 As LongPrivate Sub Command1_Click()Picture1.ClsEnd SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)If Button Thenx1 = x: y1 = yEnd IfEnd SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)If Button ThenPicture1.DrawWidth = 3Picture1.ClsPicture1.Circle (x1, y1), Sqr((x1 - x) ^ 2 + (y1 - y) ^ 2)End IfEnd Sub