Solved

how can i know the taskbar's height?

Posted on 2002-03-24
3
959 Views
Last Modified: 2008-02-01
hi experts,

when i set my form windowstate to maximized, my task bar will cove some part of the form, so i want to know the height of the taskbar in vb code, so that i can set the height of the form properly.
0
Comment
Question by:cc_2000_sg
3 Comments
 
LVL 3

Accepted Solution

by:
jbil earned 20 total points
ID: 6893249
Private Const SM_CYMAXIMIZED = 62

Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Private Sub Form_Load()
Dim screeny
screeny = GetSystemMetrics(SM_CYMAXIMIZED) * Screen.TwipsPerPixelY
Me.Left = 0
Me.Top = 0
Me.Height = screeny
End Sub
0
 
LVL 1

Expert Comment

by:Ryan_231
ID: 6893262
here's another way to get the work area of the desktop.
this takes into account that the taskbar may not
neccesarrily always be across the bottom of the screen.


Option Explicit

Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long

Const SPI_GETWORKAREA = 48


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

Dim Work As RECT

Public Sub GetWorkArea()
     Call SystemParametersInfo(SPI_GETWORKAREA, 0, Work, 0)
End Sub


Private Sub Form_Load()
  Call GetWorkArea
  Me.Caption = Work.Top & " " & Work.Right & " " & Work.Bottom & " " & Work.Left
End Sub


Work will hold the left,right,top,bottom of the usable
screen space in pixels.
0
 

Author Comment

by:cc_2000_sg
ID: 6893366
thanks, both can work.

thanks all

cc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now