vb画图板直线问题 30
PrivateSubpic2_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)IfButton=...
Private Sub pic2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then '
Select Case graphstyle
Case 2
canline = True
x0 = X
y0 = Y
xnow = X
ynow = Y
pic2.DrawMode = 7
Case 3
canrect = True
x0 = X
y0 = Y
xnow = X
ynow = Y
pic2.DrawMode = 7
Case 4
cancircle = True
x0 = X
y0 = Y
xnow = X
ynow = Y
pic2.DrawMode = 7
Case 1
canpen = True
pic2.CurrentX = X
pic2.CurrentY = Y
pic2.DrawMode = 13
End Select
End If
End Sub
Private Sub pic2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case graphstyle
Case 2
If canline Then
pic2.Line (x0, y0)-(xnow, ynow), Not (pic2.ForeColor)
pic2.Line (x0, y0)-(X, Y), Not (pic2.ForeColor)
xnow = X
ynow = Y
End If
Case 3
If canrect Then
pic2.Line (x0, y0)-(xnow, ynow), Not (pic2.ForeColor), B
pic2.Line (x0, y0)-(X, Y), Not (pic2.ForeColor), B
xnow = X
ynow = Y
End If
Case 4
r0 = Sqr((xnow - x0) ^ 2 + (ynow - y0) ^ 2)
r = Sqr((X - x0) ^ 2 + (Y - y0) ^ 2)
If cancircle Then
pic2.Circle (x0, y0), r0, Not (pic2.ForeColor)
pic2.Circle (x0, y0), r, Not (pic2.ForeColor)
xnow = X
ynow = Y
End If
Case 1
If canpen Then
pic2.Line -(X, Y), pic2.ForeColor
End If
End Select
End Sub
Private Sub pic2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case graphstyle
Case 2
canline = False
pic2.Line (x0, y0)-(xnow, ynow)
pic2.DrawMode = 13
pic2.Line (x0, y0)-(xnow, ynow), pic2.ForeColor
Case 3
canrect = False
pic2.Line (x0, y0)-(xnow, ynow), Not (pic2.ForeColor), B
pic2.DrawMode = 13
pic2.Line (x0, y0)-(xnow, ynow), pic2.ForeColor, B
Case 4
cancircle = False
pic2.Circle (x0, y0), r, Not (pic2.ForeColor)
pic2.DrawMode = 13
pic2.Circle (x0, y0), r, pic2.ForeColor
Case 1
canpen = False
End Select
End Sub
为什么直线画出来会是很多乱线,谢谢各位大侠相助 展开
If Button = 1 Then '
Select Case graphstyle
Case 2
canline = True
x0 = X
y0 = Y
xnow = X
ynow = Y
pic2.DrawMode = 7
Case 3
canrect = True
x0 = X
y0 = Y
xnow = X
ynow = Y
pic2.DrawMode = 7
Case 4
cancircle = True
x0 = X
y0 = Y
xnow = X
ynow = Y
pic2.DrawMode = 7
Case 1
canpen = True
pic2.CurrentX = X
pic2.CurrentY = Y
pic2.DrawMode = 13
End Select
End If
End Sub
Private Sub pic2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case graphstyle
Case 2
If canline Then
pic2.Line (x0, y0)-(xnow, ynow), Not (pic2.ForeColor)
pic2.Line (x0, y0)-(X, Y), Not (pic2.ForeColor)
xnow = X
ynow = Y
End If
Case 3
If canrect Then
pic2.Line (x0, y0)-(xnow, ynow), Not (pic2.ForeColor), B
pic2.Line (x0, y0)-(X, Y), Not (pic2.ForeColor), B
xnow = X
ynow = Y
End If
Case 4
r0 = Sqr((xnow - x0) ^ 2 + (ynow - y0) ^ 2)
r = Sqr((X - x0) ^ 2 + (Y - y0) ^ 2)
If cancircle Then
pic2.Circle (x0, y0), r0, Not (pic2.ForeColor)
pic2.Circle (x0, y0), r, Not (pic2.ForeColor)
xnow = X
ynow = Y
End If
Case 1
If canpen Then
pic2.Line -(X, Y), pic2.ForeColor
End If
End Select
End Sub
Private Sub pic2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case graphstyle
Case 2
canline = False
pic2.Line (x0, y0)-(xnow, ynow)
pic2.DrawMode = 13
pic2.Line (x0, y0)-(xnow, ynow), pic2.ForeColor
Case 3
canrect = False
pic2.Line (x0, y0)-(xnow, ynow), Not (pic2.ForeColor), B
pic2.DrawMode = 13
pic2.Line (x0, y0)-(xnow, ynow), pic2.ForeColor, B
Case 4
cancircle = False
pic2.Circle (x0, y0), r, Not (pic2.ForeColor)
pic2.DrawMode = 13
pic2.Circle (x0, y0), r, pic2.ForeColor
Case 1
canpen = False
End Select
End Sub
为什么直线画出来会是很多乱线,谢谢各位大侠相助 展开
3个回答
展开全部
你先试试,
在pic2_MouseDown事件中加上pic2.AutoRedraw=False
在pic2_MouseMove事件里代码前面(即Select Case前面)加上pic2.Cls
在pic2_MouseUp事件里代码前面(即Select Case前面)加上pic2.AutoRedraw=True
你再试试...
在pic2_MouseDown事件中加上pic2.AutoRedraw=False
在pic2_MouseMove事件里代码前面(即Select Case前面)加上pic2.Cls
在pic2_MouseUp事件里代码前面(即Select Case前面)加上pic2.AutoRedraw=True
你再试试...
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
画线语句上面加上cls 试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询