如何取得工作列的寬度及高度?

工作列其實是一個視窗,因此我們當作一般的視窗處理就可以了:

Option Explicit
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim TrayhWnd As Long
Dim WindowRect As RECT

Private Sub Form_Load()
TrayhWnd = FindWindow("Shell_TrayWnd", vbNullString)
GetWindowRect TrayhWnd, WindowRect
MsgBox "工作列的X軸位置: " & WindowRect.Left & vbCrLf & _
"工作列的Y軸位置: " & WindowRect.Top & vbCrLf & _
"工作列的寬度: " & WindowRect.Right - WindowRect.Left & vbCrLf & _
"工作列的高度: " & WindowRect.Bottom - WindowRect.Top, vbInformation, "工作列資料"
End
End Sub


上一頁