Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Imran  
#1 Posted : Wednesday, April 12, 2017 5:18:34 PM(UTC)
Imran

Rank: Newbie

Groups: Registered
Joined: 4/10/2017(UTC)
Posts: 6
Location: Chicago

Was thanked: 1 time(s) in 1 post(s)
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
Code:
.AddCol _
                sKey:=CStr(rs("CalendarWeekID")), _
                sHeader:=rs("ShortDescription"), _
                lWidth:=42, _
                eHeaderAlignH:=igAlignHCenter, _
                eHeaderAlignV:=igAlignVCenter



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

Imran  
#2 Posted : Wednesday, April 12, 2017 5:53:22 PM(UTC)
Imran

Rank: Newbie

Groups: Registered
Joined: 4/10/2017(UTC)
Posts: 6
Location: Chicago

Was thanked: 1 time(s) in 1 post(s)
This is what I found

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


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

thanks 1 user thanked Imran for this useful post.
Igor/10Tec on 4/13/2017(UTC)
Igor/10Tec  
#3 Posted : Thursday, April 13, 2017 1:17:14 PM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 749

Thanks: 11 times
Was thanked: 98 time(s) in 98 post(s)
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.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.