devxlogo

GetDesktopRect – Get size and position of available desktop area

GetDesktopRect – Get size and position of available desktop area

Private Type RECT    Left As Long    Top As Long    Right As Long    Bottom As LongEnd TypePrivate Const SPI_GETWORKAREA = 48Private 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=" & heSub 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 IfEnd Sub

See also  Redefining Energy Management: Advanced Solutions for Modern Buildings
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist