如何理解这个VB代码

来源:百度知道 编辑:UC知道 时间:2024/05/13 06:33:28
Private Sub Form_Load()
Me.ScaleWidth = Screen.Width
Me.ScaleHeight = Screen.Height
Me.ScaleMode = 3
Me.ScaleTop = 0
Me.ScaleLeft = 0
Me.BorderStyle = 0
Me.Scale (0, 0)-(Me.Width, Me.Height)
Me.WindowState = 2
Me.BackColor = RGB(0, 0, 0)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static LastX As Double
Static LastY As Double
If Button = 2 Then End
Line (0, 0)-(LastX, LastY), Me.BackColor
Line (0, Me.ScaleHeight)-(LastX, LastY), Me.BackColor
Line (Me.ScaleWidth, 0)-(LastX, LastY), Me.BackColor
Line (Me.ScaleWidth, Me.ScaleHeight)-(LastX, LastY), Me.BackColor
Line (Me.ScaleWidth / 2, 0)-(LastX, LastY), Me.BackColor
Line (Me.ScaleWidth / 2, Me.ScaleHeight)-(LastX, LastY), Me.BackColor
Line (0, Me.ScaleHeight / 2)-(LastX, LastY), Me.BackColor
Line (Me.ScaleWidth, Me.ScaleHeight / 2)-(LastX, LastY), Me.BackColor
Line (0, 0)

窗口加载时触发事件
Private Sub Form_Load()
头两句设置窗体为显示器窗体,可以理解为全屏(标题栏,开始菜单这些都还在的)
Me.ScaleWidth = Screen.Width
Me.ScaleHeight = Screen.Height
这句设置单位为像素还是缇之类的
Me.ScaleMode = 3
这两句设置窗口的位置,(0,0)表示左上角
Me.ScaleTop = 0
Me.ScaleLeft = 0
设置窗口的边框样式,0表示无标题栏
Me.BorderStyle = 0
Scale属性是用来实现自定义容器的坐标系统
Me.Scale (0, 0)-(Me.Width, Me.Height)
窗口状态:最大化
Me.WindowState = 2
背景颜色:黑色
Me.BackColor = RGB(0, 0, 0)
End Sub

这个是鼠标移动时触发事件
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
定义变量,用途看后面
Static LastX As Double
Static LastY As Double
鼠标右键时结束
If Button = 2 Then End
以下为画线函数
从坐标(x1,y1)-(X2,Y2)两点画线
0,0表示左上角,
0, Me.ScaleHeight表示左下角
(Me.ScaleWidth, 0)表示右上角
(Me.ScaleWidth, Me.ScaleHeight)表示右下角
(Me.ScaleWidth / 2, 0)表示上方中央
(Me.ScaleWidth / 2, Me.ScaleHeight)表示下方中央
(0, Me.ScaleHeight / 2)表示左方中央
(Me.Scale