如何用vb做一个画图板的撤销动作呢,还有如何在原有的图上划多条直线,可以像画图板上那样看到直线的轨迹
这是我编的一个算法,可以画直线,但是画第二条直线后第一条线就清除了,希望保留原来再picturebox里面的线Dimx1,x2,y1,y2AsDoubleDimDownA...
这是我编的一个算法,可以画直线,但是画第二条直线后第一条线就清除了,希望保留原来再picturebox里面的线
Dim x1, x2, y1, y2 As Double
Dim Down As Boolean
Private Sub Form_Load()
Down = False
End Sub
Private Sub pic1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
pic1.AutoRedraw = False
x1 = X: y1 = Y
x2 = X: y2 = Y
Down = True
pic1.DrawWidth = 2
pic1.PSet (X, Y), vbBlack
pic1.MousePointer = 2
End Sub
Private Sub pic1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Down = True Then
pic1.Cls
r = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ 0.5
pic1.DrawWidth = 2
pic1.Line (x1, y1)-(x2, y2), vbBlack
' pic1.Circle (x1, y1), r, vbBlack
x2 = X: y2 = Y
r = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ 0.5
End If
End Sub
Private Sub pic1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
pic1.Circle (x1, y1), r, vbBlack
Down = False
End Sub 展开
Dim x1, x2, y1, y2 As Double
Dim Down As Boolean
Private Sub Form_Load()
Down = False
End Sub
Private Sub pic1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
pic1.AutoRedraw = False
x1 = X: y1 = Y
x2 = X: y2 = Y
Down = True
pic1.DrawWidth = 2
pic1.PSet (X, Y), vbBlack
pic1.MousePointer = 2
End Sub
Private Sub pic1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Down = True Then
pic1.Cls
r = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ 0.5
pic1.DrawWidth = 2
pic1.Line (x1, y1)-(x2, y2), vbBlack
' pic1.Circle (x1, y1), r, vbBlack
x2 = X: y2 = Y
r = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ 0.5
End If
End Sub
Private Sub pic1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
pic1.Circle (x1, y1), r, vbBlack
Down = False
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询