vb6 获取系统任务栏高度
时间: 2024-04-29 10:05:14 浏览: 129
您可以使用以下代码来获取系统任务栏高度:
```
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 Const SPI_GETWORKAREA = 48
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Load()
Dim r As RECT
Dim hTaskbar As Long
Dim lHeight As Long
Call SystemParametersInfo(SPI_GETWORKAREA, 0&, r, 0&)
hTaskbar = FindWindow("Shell_TrayWnd", vbNullString)
lHeight = (r.Bottom - r.Top) - (ScaleHeight - (hTaskbar + ScaleTop))
MsgBox "Taskbar Height: " & lHeight & " pixels"
End Sub
```
此代码使用 `SystemParametersInfo` 函数来获取工作区的坐标。然后,它使用 `FindWindow` 函数找到任务栏的句柄,并将其高度与工作区高度进行比较以计算任务栏高度。
阅读全文