Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Feb 24, 2001

GetDesktopRect - Get size and position of available desktop area

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Private Const SPI_GETWORKAREA = 48

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

' Return information on screen's available area
' that is, the rectangle that isn't taken by any
' taskbar that is always visible
'
' the area size and posizion are returned in the first 4 arguments
' all values are in pixels, or in twips
' if the last argument is set to True
'
' Usage:
'   Dim le As Long, tp As Long, wi As Long, he As Long
'   GetDesktopRect le, tp, wi, he, True
'   MsgBox "Left=" & le & vbCr & "Top=" & tp & vbCr '      & "Width=" & wi & 
' vbCr & "Height=" & he

Sub GetDesktopRectt(Left As Long, Top As Long, Width As Long, Height As Long, _
    Optional ReturnAsTwips As Boolean)
    Dim lpRect As RECT
    SystemParametersInfo SPI_GETWORKAREA, 0, lpRect, 0
    ' extract values
    Left = lpRect.Left
    Top = lpRect.Top
    Width = lpRect.Right - lpRect.Left
    Height = lpRect.Bottom - lpRect.Top
    ' convert to twips if requested
    If ReturnAsTwips Then
        Left = Left * Screen.TwipsPerPixelX
        Top = Top * Screen.TwipsPerPixelY
        Width = Width * Screen.TwipsPerPixelX
        Height = Height * Screen.TwipsPerPixelY
    End If
End Sub
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date