Access/VBA Library

ScreenHeight

Returns the height of the screen.

Syntax

ScreenHeight()
Return value

Long : The height of the screen in twips.

Code
Public Function ScreenHeight() As Long
    Const HWND_DESKTOP As Long = 0
    Const LOGPIXELSY As Long = 90
    Dim lngDC As Long
    Dim TwipsPerPixelY As Single
    
    lngDC = GetDC(HWND_DESKTOP)
    TwipsPerPixelY = 1440& / GetDeviceCaps(lngDC, LOGPIXELSY)
    ReleaseDC HWND_DESKTOP, lngDC

    ScreenHeight = GetSystemMetrics32(1) * TwipsPerPixelY
End Function
Systemtag:System

See also

  • GetDC
  • ReleaseDC
  • GetDeviceCaps