Hi, I tested this code and it works on XP and Seven, the only thing it doesn't do is adjust when the autohide property is set on and the taskbar is hidden. I found a way to determine if the taskbar is set to autohide, although is there a way to determine if the taskbar is hidden at the moment (right click the taskbar -> properties -> autohide the taskbar)?
Declarations in a module
Functions in the module:Code:Option Explicit Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type APPBARDATA cbSize As Long hwnd As Long uCallbackMessage As Long uEdge As Long rc As RECT lParam As Long End Type Const ABS_ALWAYSONTOP = &H2 Const ABS_AUTOHIDE = &H1 Const ABS_BOTH = &H3 Const ABM_GETSTATE = &H4 Const ABM_GETAUTOHIDEBAR = &H7 Const ABM_GETTASKBARPOS = &H5 Const ABE_LEFT = 0 Const ABE_TOP = 1 Const ABE_RIGHT = 2 Const ABE_BOTTOM = 3 Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
Example of usage:Code:Public Function GetTaskBarMetrics() As String Dim ABD As APPBARDATA ABD.cbSize = Len(ABD) SHAppBarMessage ABM_GETTASKBARPOS, ABD GetTaskBarMetrics = "TaskBarMetrics In Pixels (not twips)" & vbCrLf & _ "Left: " & ABD.rc.Left & ", Right: " & ABD.rc.Right & ", Bottom: " & ABD.rc.Bottom & ", Top: " & ABD.rc.Top & vbCrLf & _ "Width:" & ABD.rc.Right - ABD.rc.Left & vbCrLf & _ "Height:" & ABD.rc.Bottom - ABD.rc.Top & vbCrLf & _ "Location: " & ABD.uEdge & " (0-left, 1-top, 2-right, 3-bottom)" End Function Public Function TaskBarState() As String Dim ABD As APPBARDATA, res& ABD.cbSize = Len(ABD) res = SHAppBarMessage(ABM_GETSTATE, ABD) If res = 0 Then TaskBarState = "TaskBar not in auto-hide or always-on-top mode" ElseIf res = ABS_ALWAYSONTOP Then TaskBarState = "TaskBar always-on-top mode" ElseIf res = ABS_AUTOHIDE Then TaskBarState = "TaskBar is in auto-hide mode" ElseIf res = ABS_BOTH Then TaskBarState = "TaskBar is always-on-top and auto-hide modes" Else TaskBarState = "Unknown" End If End Function
I modified the code from here http://support.microsoft.com/kb/143117 and here http://vbnet.mvps.org/index.html?cod...barmessage.htmCode:Private Sub Command1_Click() MsgBox GetTaskBarMetrics MsgBox TaskBarState End Sub




Reply With Quote