Results 1 to 28 of 28

Thread: [RESOLVED] Task Bar Metrics - when is the Taskbar Auto Hidden?

Threaded View

  1. #1

    Thread Starter
    Addicted Member Witis's Avatar
    Join Date
    Jan 2011
    Location
    VB Forums Online Freedom Mode: Operational
    Posts
    213

    Resolved [RESOLVED] Task Bar Metrics - when is the Taskbar Auto Hidden?

    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
    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
    Functions in the module:
    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
    Example of usage:
    Code:
    Private Sub Command1_Click()
    MsgBox GetTaskBarMetrics
    MsgBox TaskBarState
    End Sub
    I modified the code from here http://support.microsoft.com/kb/143117 and here http://vbnet.mvps.org/index.html?cod...barmessage.htm
    Last edited by Witis; Mar 9th, 2011 at 11:11 PM. Reason: Updated after comments from LaVolpe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width