Get Screen Size

Viewed 14

I am using this code to retrieve the active screen size of a form.

Dim lngHWND             As Long
Dim hMonitor            As Long
Dim MonitorInfo         As typMonitorInfo
Dim apiReturnCode       As Long

lngHWND = frm.hwnd

hMonitor = MonitorFromWindow(lngHWND, MONITOR_DEFAULTTONEAREST)
MonitorInfo.cbSize = LenB(MonitorInfo)

apiReturnCode = GetMonitorInfo(hMonitor, VarPtr(MonitorInfo))

' Récupération de la taille de l'écran
With MonitorInfo.rcMonitor
    dblWidth_Ecran = (.Right - .Left)
    dblHeight_Ecran = (.Bottom - .Top)
End With

On my screens, if I set 1920x1080, it goes back to 1920x1080. If I switch to 125% scaling, it brings me back 1536x864 (1920/1.25 & 108/1.25). Which suits me perfectly.

On the other hand, on other workstations (client side), it always goes back to 1920x1080, whatever the scaling.

Do you have an explanation or any leads to use to make it functional, as in the first case?

Best regards,

0 Answers
Related