⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 很好的教程原代码!
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4740
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6930
   LinkTopic       =   "Form1"
   ScaleHeight     =   4740
   ScaleWidth      =   6930
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "获取桌面大小"
      Height          =   495
      Left            =   1800
      TabIndex        =   0
      Top             =   3360
      Width           =   1455
   End
   Begin VB.Label Label4 
      Height          =   495
      Left            =   840
      TabIndex        =   4
      Top             =   2280
      Width           =   3135
   End
   Begin VB.Label Label3 
      Height          =   495
      Left            =   840
      TabIndex        =   3
      Top             =   1560
      Width           =   3135
   End
   Begin VB.Label Label2 
      Height          =   420
      Left            =   840
      TabIndex        =   2
      Top             =   960
      Width           =   3180
   End
   Begin VB.Label Label1 
      Height          =   375
      Left            =   840
      TabIndex        =   1
      Top             =   360
      Width           =   3135
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' 函数声明
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _
    (ByVal uAction As Long, _
    ByVal uParam As Long, _
    ByVal lpvParam As Any, _
    ByVal fuWinIni As Long _
    ) As Long
'常量声明
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Private Const SPI_GETWORKAREA = 48

Private Sub GetScrSize()
    Dim lRet As Long
    Dim apiRECT As RECT
    lRet = SystemParametersInfo(SPI_GETWORKAREA, vbNull, VarPtr(apiRECT), 0)
    If lRet Then
        Form1.Label1.Caption = "Left: " & apiRECT.Left
        Form1.Label2.Caption = "Top: " & apiRECT.Top
        Form1.Label3.Caption = "Width: " & apiRECT.Right - apiRECT.Left
        Form1.Label4.Caption = "Height: " & apiRECT.Bottom - apiRECT.Top
    Else
        Form1.Label1.Caption = "调用 SystemParametersInfo 失败"
    End If
End Sub

Private Sub Command1_Click()
GetScrSize
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -