2个回答
展开全部
能,几个API函数的事情
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal Hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Command1_Click()
Dim Hwnd As Long
Dim WinRECT As RECT
Hwnd = FindWindow("Shell_TrayWnd", vbNullString)
GetWindowRect Hwnd, WinRECT
MsgBox "任务栏长度: " & WinRECT.Right - WinRECT.Left & vbCrLf & "任务栏宽度: " & WinRECT.Bottom - WinRECT.Top, , "单位:Pixel"
End Sub
得出的宽度,长度单位是Pixel,根据你的需要换算一下,如果你的窗体是Twip模式的那么就把原值乘以15就好了。
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal Hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Command1_Click()
Dim Hwnd As Long
Dim WinRECT As RECT
Hwnd = FindWindow("Shell_TrayWnd", vbNullString)
GetWindowRect Hwnd, WinRECT
MsgBox "任务栏长度: " & WinRECT.Right - WinRECT.Left & vbCrLf & "任务栏宽度: " & WinRECT.Bottom - WinRECT.Top, , "单位:Pixel"
End Sub
得出的宽度,长度单位是Pixel,根据你的需要换算一下,如果你的窗体是Twip模式的那么就把原值乘以15就好了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询