User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 456,553 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,460 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 2198 | Replies: 5
Reply
Join Date: Nov 2005
Location: Montreal, QC (Almost)
Posts: 130
Reputation: Yomet is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 9
Yomet Yomet is offline Offline
Junior Poster

Getting the height of the taskbar in VB

  #1  
Oct 15th, 2007
Hi,

I have a form of variable height. When the form grows in height I have code that verifies if the bottom of the form will come below the bottom of the screen and, if so, moves the form up - no problem until here.

However, some of my users have taskbars that are two lines in height and my code only deals with sinlge-line taskbars by moving the form 450 twips further up (hardcoded is bad - I know). I would like to be able to tell how high the taskbar is and then move the form accordingly.

Here's my current code:
Private Sub cmdGrowForm_Click()
   Dim NewH As Integer
   Dim TBarH As Integer
   
   TBarH = 450 'Assumes a single row taskbar
   NewH = 11010   'New form height
   If Me.Top + NewH + TBarH > Screen.Height Then
      Me.Top = Screen.Height - NewH - TBarH
   End If
   Me.Height = NewH
End Sub

So my question is - is there a way of getting the taskbar height in VB?

Could somebody try to point me in the correct direction? Even if it is only "You can't get the taskbar height in VB." as answer that's great for me.

Thanks

Yomet
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2006
Posts: 30
Reputation: yello is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
yello yello is offline Offline
Light Poster

Re: Getting the height of the taskbar in VB

  #2  
Oct 15th, 2007
Using the following API function you can get it!!

Private Const ABM_GETTASKBARPOS = &H5

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

Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long


Function GetTaskBarSize()
    Dim ABD As APPBARDATA

    SHAppBarMessage ABM_GETTASKBARPOS, ABD

    MsgBox "Width:" & ABD.rc.Right - ABD.rc.Left 
    MsgBox " Height:" & ABD.rc.Bottom -    ABD.rc.Top

End Sub
www.easyprograming.com
Make Your Programing Easy
Reply With Quote  
Join Date: Oct 2007
Posts: 145
Reputation: hopalongcassidy is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 13
hopalongcassidy's Avatar
hopalongcassidy hopalongcassidy is offline Offline
Junior Poster

Re: Getting the height of the taskbar in VB

  #3  
Oct 16th, 2007
Originally Posted by yello View Post
Using the following API function you can get it!!

Private Const ABM_GETTASKBARPOS = &H5

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

Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long


Function GetTaskBarSize()
    Dim ABD As APPBARDATA

    SHAppBarMessage ABM_GETTASKBARPOS, ABD

    MsgBox "Width:" & ABD.rc.Right - ABD.rc.Left 
    MsgBox " Height:" & ABD.rc.Bottom -    ABD.rc.Top

End Sub


Hey, that's pretty nifty!

Hoppy
Reply With Quote  
Join Date: Nov 2005
Location: Montreal, QC (Almost)
Posts: 130
Reputation: Yomet is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 9
Yomet Yomet is offline Offline
Junior Poster

Re: Getting the height of the taskbar in VB

  #4  
Oct 18th, 2007
Yello,

Thanks a million, it works flawlessly.

Yomet
Reply With Quote  
Join Date: Nov 2006
Posts: 30
Reputation: yello is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
yello yello is offline Offline
Light Poster

Re: Getting the height of the taskbar in VB

  #5  
Oct 18th, 2007
Yomet, you are most welcome
www.easyprograming.com
Make Your Programing Easy
Reply With Quote  
Join Date: Oct 2007
Posts: 5
Reputation: tzatziki is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
tzatziki tzatziki is offline Offline
Newbie Poster

Re: Getting the height of the taskbar in VB

  #6  
Oct 22nd, 2007
But be warned that not all users have the taskbar in bottom or even in the screen that your program runs (ex. they may have two different screens side by side)
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 5:20 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC