modapiwindows.bas

来自「vb开发的学籍管理系统」· BAS 代码 · 共 31 行

BAS
31
字号
Attribute VB_Name = "ModAPIWindows"
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long
Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Public Const SW_Minimize = 6
Public Const SW_Maximize = 3
Public Const SW_Normal = 1

Public TargetList As ListBox

Public Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
  Dim SLength As Long, Buffer As String  ' title bar text length and buffer
  Dim RetVal As Long  ' return value
  Static WinNum As Integer  ' counter keeps track of how many windows have been enumerated

  WinNum = WinNum + 1  ' one more window enumerated....
  SLength = GetWindowTextLength(hWnd) + 1  ' get length of title bar text
  If SLength > 1 Then  ' if return value refers to non-empty string
    Buffer = Space(SLength)  ' make room in the buffer
    RetVal = GetWindowText(hWnd, Buffer, SLength)  ' Get title bar text.
    TargetList.AddItem Left(Buffer, SLength - 1)  '
    TargetList.ItemData(TargetList.NewIndex) = hWnd '
  End If

  EnumWindowsProc = 1  ' return value of 1 means continue enumeration
' --------------------------------------------------------------------------------- '
End Function

⌨️ 快捷键说明

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