利用LINE命令画矩形的问题。
本人是一个初学者,看到书中有如下代码,是利用line命令画矩形的。
Dim xp1 As Single, yp1 As Single
Dim xp2 As Single, yp2 As Single
Dim drawing As Boolean 'boolean表示布尔型变量(只有True(真)和False(假)两种值)
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not drawing Then
xp1 = X: yp1 = Y
xp2 = X: yp2 = Y
drawing = True
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If drawing Then
DrawStyle = 2
DrawMode = vbInvert
Line (xp1, yp1)-(xp2, yp2), , B
Line (xp1, yp1)-(X, Y), , B
xp2 = X: yp2 = Y
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If drawing Then
DrawMode = vbBlackness
DrawStyle = 0
Line (xp1, yp1)-(X, Y), , B
drawing = False
End If
End Sub
我想问一下,各位高手。 一、为什么要添加DrawMode = vbInvert
二、Line (xp1, yp1)-(xp2, yp2), , B
Line (xp1, yp1)-(X, Y), , B
为什么写两次矩形框的代码?
小弟实在搞不懂,望各位高手不惜赐教!谢谢