求用vb编一段简单的用鼠标拖动画直线的程序!
来源:百度知道 编辑:UC知道 时间:2024/05/17 22:24:20
回一楼沙发的那位,不好意思,因为还有其他的背景图,所以不能用Form1.Cls语句吧?
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
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