Imran
  • Imran
  • Member Topic Starter
2017-04-12T17:18:34Z
I have users that now have machines with HD displays where the OS scaling is being set to 125% to 200% depending on the machine. Since iGrid column widths are set in pixels when a machine set to 200% scaling the columns appear very skinny. How can I pull this OS setting into my Access application? How is the setting reported and how do I apply it to my existing column widths so the application appears normal to the user.

I'm assuming I would need to convert instances of this
.AddCol _
                sKey:=CStr(rs("CalendarWeekID")), _
                sHeader:=rs("ShortDescription"), _
                lWidth:=42, _
                eHeaderAlignH:=igAlignHCenter, _
                eHeaderAlignV:=igAlignVCenter



.AddCol _
                sKey:=CStr(rs("CalendarWeekID")), _
                sHeader:=rs("ShortDescription"), _
                lWidth:=lScalingFactor * 42, _
                eHeaderAlignH:=igAlignHCenter, _
                eHeaderAlignV:=igAlignVCenter

Imran
  • Imran
  • Member Topic Starter
2017-04-12T17:53:22Z
This is what I found

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


This seems to return 96 if the setting is 100% and then the Scaling Setting * 96 for higher levels.
For example if the scaling setting is set to 125%, this function returns 120.
I should be able to use this to determine the ScalingMultiplier that needs to be applied to all column width settings
I tested this on my desktop machine as well as a SurfacePro4 and it seemed to be consistent.

Imran

Igor/10Tec
2017-04-13T13:17:14Z
A good resource to find out more about DPI-aware applications in Windows is the following MSDN article:

Writing DPI-Aware Desktop and Win32 Applications 

Pay attention to the fact that starting from Windows 8.1 applications can change their contents dynamically in a multi-monitor configuration when the monitors have different DPI values (so called "per monitor–DPI aware applications"). However, in the case of iGrid and apps hosting it, I think it will be enough to worry only about the system DPI value in the nearest few years.