求用vb编一段简单的用鼠标拖动画直线的程序!
就是类似与vb中画直线的控件的那种画图程序,在点按下鼠标左键的同时开始画线,抬起鼠标左键的地方是终点,做一条线,线的颜色要可以自己调,不过在拖动鼠标时可以看到划线的过程以...
就是类似与vb中画直线的控件的那种画图程序,在点按下鼠标左键的同时开始画线,抬起鼠标左键的地方是终点,做一条线,线的颜色要可以自己调,不过在拖动鼠标时可以看到划线的过程以便调整,我自己编的时候,因为拖到哪里就会把线画到哪里,不能删掉原来的线,所以一拖动鼠标就会出现好多线,有人说要把先前拖出来的线和背景色异或一下之类的,我不知道该怎么做,谁能帮帮我!多谢!
回一楼沙发的那位,不好意思,因为还有其他的背景图,所以不能用Form1.Cls语句吧? 展开
回一楼沙发的那位,不好意思,因为还有其他的背景图,所以不能用Form1.Cls语句吧? 展开
2个回答
展开全部
Dim xpos As Single, ypos As Single
Private Sub Form_Load()
Me.MousePointer = 2
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'若要自己调颜色 工程-部件-microsoft common dialog control 6.0打钩-确定,添加一个commondialog控件并去掉下面两句的注释符
'If Button = 2 Then Me.CommonDialog1.ShowColor
'Me.ForeColor = Me.CommonDialog1.Color
Me.AutoRedraw = False
xpos = X: ypos = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Refresh
If Button = 1 Then Line (xpos, ypos)-(X, Y)
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.AutoRedraw = True
Line (xpos, ypos)-(X, Y)
End Sub
Private Sub Form_Load()
Me.MousePointer = 2
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'若要自己调颜色 工程-部件-microsoft common dialog control 6.0打钩-确定,添加一个commondialog控件并去掉下面两句的注释符
'If Button = 2 Then Me.CommonDialog1.ShowColor
'Me.ForeColor = Me.CommonDialog1.Color
Me.AutoRedraw = False
xpos = X: ypos = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Refresh
If Button = 1 Then Line (xpos, ypos)-(X, Y)
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.AutoRedraw = True
Line (xpos, ypos)-(X, Y)
End Sub
展开全部
Public WithEvents Liness As Line
Public Counts As Integer
Public isCan As Boolean
Private Sub Form_Load()
Counts = 0
isCan = False
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Set Liness = Controls.Add("vb.line", "Liness" & Counts)
isCan = True
Counts = Count + 1
Liness.x1 = X
Liness.y1 = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 And isCan = True Then
Liness.Visible = True
Liness.X2 = X
Liness.Y2 = Y
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
isCan = False
End Sub
Public Counts As Integer
Public isCan As Boolean
Private Sub Form_Load()
Counts = 0
isCan = False
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Set Liness = Controls.Add("vb.line", "Liness" & Counts)
isCan = True
Counts = Count + 1
Liness.x1 = X
Liness.y1 = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 And isCan = True Then
Liness.Visible = True
Liness.X2 = X
Liness.Y2 = Y
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
isCan = False
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询