module1.bas

来自「Desktop LockDesktop LockDesktop Lock」· BAS 代码 · 共 31 行

BAS
31
字号
Attribute VB_Name = "Module1"
Public Declare Function EnumWindows Lib "user32" _
     (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
     (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Declare Function ShowWindow Lib "user32" (ByVal _
     hwnd As Long, ByVal nCmdShow As Long) As Long

    Public Const WS_MINIMIZEBOX = &H20000
    Public Const WS_VISIBLE = &H10000000
    Public Const GWL_STYLE = (-16)
    Public Const SW_MINIMIZE = 6

    '该函数是EnumWindows的回调函数,
    'EnumWindows函数将遍历的窗口句柄传递到hwnd参数中
    Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
     Dim l As Long
     Dim ld As Long
     ld = GetWindowLong(hwnd, GWL_STYLE)
     '如果窗口具有最小化按钮并且窗口是可见的就将该窗口最小化
     If ((ld And WS_MINIMIZEBOX) = WS_MINIMIZEBOX) Then
     If ((ld And WS_VISIBLE)) Then
     If ShowWindow(hwnd, SW_MINIMIZE) Then
     End If
     End If
     End If
     EnumWindowsProc = True
    End Function


⌨️ 快捷键说明

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