I have a form that doesn't really fit fully on the screen with scaling set to 125% or more in Windows 10 in Full HD resolution, so I want another form to be loaded instead if users have scaling over 100%.
I already have code which checks if users have lower screen resolution, but I haven't been able to find a working way to deal with Windows scaling.
I found some code that's obtaining your current DPI, but for some reason it always seems to show 96 regardless of what scaling I use.
I have dual monitors and have tried changing scaling to 125% and 150% on both, but the number shown will always be 96 for some reason.
Does anyone know how to properly check this in another way? Perhaps by reading a Windows registry key or something like that?
Thank you
I already have code which checks if users have lower screen resolution, but I haven't been able to find a working way to deal with Windows scaling.
I found some code that's obtaining your current DPI, but for some reason it always seems to show 96 regardless of what scaling I use.
I have dual monitors and have tried changing scaling to 125% and 150% on both, but the number shown will always be 96 for some reason.
Does anyone know how to properly check this in another way? Perhaps by reading a Windows registry key or something like that?
Thank you
Code:
Option Compare Database
Option Explicit
Private Const LOGPIXELSX As Long = 88
Private Declare Function GetDeviceCaps Lib "gdi32.dll" ( _
ByVal hdc As Long, _
ByVal nIndex As Long) As Long
Private Declare Function GetDC Lib "user32.dll" ( _
ByVal hWnd As Long) As Long
Declare Function ReleaseDC Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal hdc As Long) As Long
Public Function GetDPI() As Long
Dim hdcScreen As Long
Dim iDPI As Long
iDPI = -1
hdcScreen = GetDC(0)
If (hdcScreen) Then
iDPI = GetDeviceCaps(hdcScreen, LOGPIXELSX)
ReleaseDC 0, hdcScreen
End If
GetDPI = iDPI
End Function