vb中实现用鼠标绘制直线的代码
2个回答
展开全部
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then
Picture1.Cls '按右键可清屏
ElseIf Picture1.CurrentX = 0 And Picture1.CurrentY = 0 Then
Picture1.PSet (X, Y), vbBlack '开始画第一个点
Else
Picture1.Line -(X, Y), vbBlack '画线
End If
End Sub
If Button <> 1 Then
Picture1.Cls '按右键可清屏
ElseIf Picture1.CurrentX = 0 And Picture1.CurrentY = 0 Then
Picture1.PSet (X, Y), vbBlack '开始画第一个点
Else
Picture1.Line -(X, Y), vbBlack '画线
End If
End Sub
展开全部
Private Sub pic1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If pic1.CurrentX = 0 And pic1.CurrentY = 0 Then
pic1.PSet (x, y), RGB(0, 0, 0)
Else
pic1.Line -(x, y), RGB(0, 0, 0)
End If
End Sub
用一个PictureBox名称为pic1。
下面的代码使它占满窗体:
Private Sub Form_Load()
picSize
End Sub
Private Sub Form_Resize()
picSize
End Sub
Private Sub picSize()
pic1.Height = Me.Height
pic1.Width = Me.Width
pic1.Top = 0
pic1.Left = 0
End Sub
用PictureBox时,如果想看不出来,可以把pic1的BorderStyle设为0。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询