Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Measuring the Windows taskbar 2

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
GB
I would like my app to size itself according to the visible space on the Windows desktop, taking into account the size and position of the Windows taskbar so that it does not obscure it (assuming users don't have the Taskbar set as 'Always visible').

Does anyone know how to get the size and position of the Taskbar?

- Andy.
 
Here's a funtion that returns the bounding rect for the task bar (values in pixels)

Option Explicit

Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long
End Type

Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
Public Const ABM_GETTASKBARPOS = &H5

Public Function GetTaskbarRect() As RECT
Dim result As Long
Dim Bardata As APPBARDATA

result = SHAppBarMessage(ABM_GETTASKBARPOS, Bardata)
GetTaskbarRect = Bardata.rc
End Function
 
Check out the SysInfo Control for VB6. It has WorkAreaLeft, Top, Height and Width. Don't forget that the Taskbar can be docked Left, Right To bottom. Add the MS Sysinfo Control 6.6.
"WorkAreaHeight Property

Returns the height of the visible desktop adjusted for the Windows taskbar. Not available at design time.

Syntax

object.WorkAreaHeight

The object placeholder represents anobject expression that evaluates to an object in the Applies To list.

Remarks

When the taskbar appears along the top or bottom of the screen, the WorkAreaHeight property tells you the height of the visible desktop less the height of the taskbar."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top