VB,帮我在每行的后面翻译这个小程序,我交作业,要求尽量详细

来源:百度知道 编辑:UC知道 时间:2024/05/22 02:11:30
Option Explicit
Const SPI_GETWORKAREA = 48

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, _
ByVal fuWinIni As Long) As Long

Private Sub Command1_Click()
Dim lRet As Long
Dim apiRECT As RECT

lRet = SystemParametersInfo(SPI_GETWORKAREA, vbNull, apiRECT, 0)
If lRet Then
Label1.Caption = "宽: " & apiRECT.Right - apiRECT.Left & " 高: " & apiRECT.Bottom - apiRECT.Top
Else
Print "调用 SystemParametersInfo 失败"
End If
End Sub

Private Sub Command2_Click()
End
End Sub

Option Explicit '声明以下语句必须按完整规范书写
Const SPI_GETWORKAREA = 48 '定义常量

Private Type RECT '自定义变量结构,rect通常用于确定矩形范围
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, _
ByVal fuWinIni As Long) As Long '声明API

Private Sub Command1_Click() '按钮一单击事件过程
Dim lRet As Long ’变量声明为长整形
Dim apiRECT As RECT ’声明变量为自定义结构

lRet = SystemParametersInfo(SPI_GETWORKAREA, vbNull, apiRECT, 0) '调用api将窗口值写入自定义结构,并返回是否成功。
If lRet Then '返回非零则执行
Label1.Caption = "宽: " & apiRECT.Right - apiRECT.Left & " 高: " & apiRECT.Bottom - apiRECT.Top '成功则写出到标签
Else '返回零则失败
Print "调用 SystemParametersInfo 失败" '提示失败
En