Windows TaskBar info
Posted: Thu Mar 15, 2012 4:35 pm
While adding the Snap to Window Height, I wanted to make the Task Bar height system-aware, rather than a constant. I came across this post on c#, so I converted some of its functionality to PB, but in two procs.
http://www.pcreview.co.uk/forums/taskba ... 87688.html
Right now, I used two procs for the two return values, and I left in all of the debug info. I hope someone can appreciate it.
Also, if anybody has a Linux or Mac version, that would be great.
PB code:
http://www.pcreview.co.uk/forums/taskba ... 87688.html
Right now, I used two procs for the two return values, and I left in all of the debug info. I hope someone can appreciate it.
Also, if anybody has a Linux or Mac version, that would be great.
PB code:
Code: Select all
; Enum ABMsg
Enumeration
#ABM_NEW = 0
#ABM_REMOVE = 1
#ABM_QUERYPOS = 2
#ABM_SETPOS = 3
#ABM_GETSTATE = 4
#ABM_GETTASKBARPOS = 5
#ABM_ACTIVATE = 6
#ABM_GETAUTOHIDEBAR = 7
#ABM_SETAUTOHIDEBAR = 8
#ABM_WINDOWPOSCHANGED = 9
#ABM_SETSTATE = 10
EndEnumeration
; Enum ABEdge
Enumeration
#ABE_LEFT = 0
#ABE_TOP
#ABE_RIGHT
#ABE_BOTTOM
EndEnumeration
; Enum ABState
Enumeration
#ABS_MANUAL = 0
#ABS_AUTOHIDE = 1
#ABS_ALWAYSONTOP = 2
#ABS_AUTOHIDEANDONTOP = 3
EndEnumeration
; Enum TaskBarEdge
Enumeration
#Bottom
#Top
#Left
#Right
EndEnumeration
Procedure.i GetTaskBarHeight()
abd.APPBARDATA ;APPBARDATA abd = new APPBARDATA();
height = 0
taskBarEdge = #Bottom
; TaskBarEdge & Height
SHAppBarMessage_(#ABM_GETTASKBARPOS, abd)
Select (abd\uEdge)
Case #ABE_BOTTOM:
Debug "Taskbar on bottom."
Debug "bottom=" + Str(abd\rc\bottom) + ", top=" +Str(abd\rc\top)
taskBarEdge = #Bottom
height = abd\rc\bottom - abd\rc\top
Case #ABE_TOP:
Debug "Taskbar on top."
Debug "bottom=" + Str(abd\rc\bottom) + ", top= NA"
taskBarEdge = #Top
height = abd\rc\bottom
Case #ABE_LEFT:
Debug "Taskbar on left."
Debug "right=" + Str(abd\rc\right) + ", left=" +Str(abd\rc\left)
taskBarEdge = #Left;
height = abd\rc\right - abd\rc\left
Case #ABE_RIGHT:
Debug "Taskbar on right."
Debug "right=" + Str(abd\rc\right) + ", left=" +Str(abd\rc\left)
taskBarEdge = #Right
height = abd\rc\right - abd\rc\left
EndSelect
Debug "hgt = " + Str(height)
ProcedureReturn height
EndProcedure
Procedure.i GetTaskBarAutoHide()
autoHide = false
; TaskBar AutoHide Property
abd.APPBARDATA ;abd = new APPBARDATA();
uState.i = SHAppBarMessage_(#ABM_GETSTATE, abd);
Select (uState)
Case #ABS_ALWAYSONTOP:
autoHide = #False
Case #ABS_AUTOHIDE:
autoHide = #True
Case #ABS_AUTOHIDEANDONTOP:
autoHide = #True
Case #ABS_MANUAL:
autoHide = #False
EndSelect
Debug "autohide = " + Str(autoHide)
ProcedureReturn autoHide
EndProcedure
Debug "height return value: " + Str(GetTaskBarHeight())
Debug "AutoHide return value: " + Str(GetTaskBarAutoHide())