|
-
Nov 8th, 2009, 02:20 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Detect taskbar height
I have routine that checks users resolution and adjust the form height using this:
Code:
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYMAXIMIZED = 62
Public Const SM_CXFULLSCREEN = 16
Public Const SM_CYFULLSCREEN = 17
Public Sub MaxFormHeight(frm As Form)
Dim lgScreenY As Long
lgScreenY = GetSystemMetrics(SM_CYMAXIMIZED)
frm.Height = Screen.Height - lgScreenY
End Sub
Detect taskbar height
I have routine that checks users resolution and adjust the form height using this:
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYMAXIMIZED = 62
Public Const SM_CXFULLSCREEN = 16
Public Const SM_CYFULLSCREEN = 17
Public Sub MaxFormHeight(frm As Form)
Dim lgScreenY As Long
lgScreenY = GetSystemMetrics(SM_CYMAXIMIZED)
frm.Height = Screen.Height - lgScreenY
End Sub
I am not concerned with the forms width only the height. This works fine until a user increases the taskbar height. Then when the form loads it does not allow for the increased height of the taskbar. The taskbar then covers the bottom portion of the form. How can i correct this ?
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Nov 8th, 2009, 02:33 PM
#2
Re: Detect taskbar height
The taskbar can also be along the left or right side of the screen, which may mess you up with the approach from the OP.
Better to use the system's desktop dimensions. Send four variables to the following function and they'll get stuffed (by reference) with the usable desktop's dimensions:
vb Code:
' Get desktop coords excluding any taskbars
' Thanks to bushmobile from vbforums.com
Public Sub GetDesktop(plngLeft As Long, plngTop As Long, plngWidth As Long, plngHeight As Long)
Const SPI_GETWORKAREA As Long = 48
Dim rc As rect
Call SystemParametersInfo(SPI_GETWORKAREA, 0&, rc, 0&)
With rc
plngLeft = .Left * Screen.TwipsPerPixelX
plngTop = .Top * Screen.TwipsPerPixelY
plngWidth = (.Right - .Left) * Screen.TwipsPerPixelX
plngHeight = (.Bottom - .Top) * Screen.TwipsPerPixelY
End With
End Sub
-
Nov 8th, 2009, 10:54 PM
#3
Thread Starter
PowerPoster
Re: Detect taskbar height
 Originally Posted by Ellis Dee
The taskbar can also be along the left or right side of the screen, which may mess you up with the approach from the OP.
Better to use the system's desktop dimensions. Send four variables to the following function and they'll get stuffed (by reference) with the usable desktop's dimensions:
vb Code:
' Get desktop coords excluding any taskbars
' Thanks to bushmobile from vbforums.com
Public Sub GetDesktop(plngLeft As Long, plngTop As Long, plngWidth As Long, plngHeight As Long)
Const SPI_GETWORKAREA As Long = 48
Dim rc As rect
Call SystemParametersInfo(SPI_GETWORKAREA, 0&, rc, 0&)
With rc
plngLeft = .Left * Screen.TwipsPerPixelX
plngTop = .Top * Screen.TwipsPerPixelY
plngWidth = (.Right - .Left) * Screen.TwipsPerPixelX
plngHeight = (.Bottom - .Top) * Screen.TwipsPerPixelY
End With
End Sub
Thanks, That works
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Feb 19th, 2015, 08:01 PM
#4
Hyperactive Member
Re: [RESOLVED] Detect taskbar height
I placed this code into module:
Code:
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_CXSCREEN = 0
Private Const SM_CYMAXIMIZED = 62
Public Const SM_CXFULLSCREEN = 16
Public Const SM_CYFULLSCREEN = 17
Public Sub MaxFormHeight(frm As Form)
Dim lgScreenY As Long
lgScreenY = GetSystemMetrics(SM_CYMAXIMIZED)
frm.Height = Screen.Height - lgScreenY
End Sub
In the form_load I placed
Code:
Private Sub Form_Load()
MaxFormHeight (Me)
End Sub
I get Type Mismatch Error
Last edited by chapran; Feb 20th, 2015 at 08:00 AM.
-
Feb 19th, 2015, 09:17 PM
#5
Re: [RESOLVED] Detect taskbar height
Remove the parentheses from ME
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|