Hi Dan.
Look at here:
https://community.appeon.com/index.php/qna/q-a/monitor-scale-factor
Guys already help me solve similar problem.
I need to check user display resolution for some some screens in our app, i am doing on the screen level.
First, global functions need to be declared, i did at the application level:
FUNCTION Longptr GetDC ( Longptr hWnd ) LIBRARY "user32.dll"
FUNCTION Longptr GetDesktopWindow ( ) LIBRARY "user32.dll"
FUNCTION UnsignedLong GetDeviceCaps ( Longptr hDC, UnsignedLong nIndex ) LIBRARY "gdi32.dll"
FUNCTION Long ReleaseDC ( Longptr hWnd, Longptr hDC ) LIBRARY "user32.dll"
Second, i create functions:
global type f_check_display_settings from function_object
end type
forward prototypes
global function boolean f_check_display_settings (long ar_l_screen_width, long ar_l_screen_height, string ar_s_window_title)
end prototypes
global function boolean f_check_display_settings (long ar_l_screen_width, long ar_l_screen_height, string ar_s_window_title);environment env
int i_rc
long l_screenwidth, l_screenheight
string s_width, s_height
Constant ULong LOGPIXELSX = 88, LOGPIXELSY = 90
Long ll_rc, ll_percent
ULong lul_dpi_x, lul_dpi_y
Longptr llptr_hwnd, llptr_hdc
i_rc = GetEnvironment(env)
IF i_rc <> 1 THEN
messagebox('System Error', 'Cannot verify monitor screen size.~nPlease contact system administrator.~n~nGetEnvironment()=' + string(i_rc), exclamation!)
return false
end if
l_screenwidth = env.ScreenWidth
l_screenheight = env.ScreenHeight
if isnull(l_screenwidth) then
s_width = 'Null'
else
s_width = string(l_screenwidth)
end if
if isnull(l_screenheight) then
s_height = 'Null'
else
s_height = string(l_screenheight)
end if
IF isnull(l_screenwidth + l_screenheight) = true or l_screenwidth + l_screenheight < 1 THEN
messagebox('System Error', 'Cannot verify monitor screen size.~nPlease contact system administrator.~n~nScreenWidth=' + s_width + ', ScreenHeight=' + s_height, exclamation!)
return false
end if
if env.osmajorrevision < 10 then
// Script begin ...
/*
Global external functions need to be declared in the application object:
FUNCTION Longptr GetDC ( Longptr hWnd ) LIBRARY "user32.dll"
FUNCTION Longptr GetDesktopWindow ( ) LIBRARY "user32.dll"
FUNCTION UnsignedLong GetDeviceCaps ( Longptr hDC, UnsignedLong nIndex ) LIBRARY "gdi32.dll"
FUNCTION Long ReleaseDC ( Longptr hWnd, Longptr hDC ) LIBRARY "user32.dll"
*/
llptr_hwnd = GetDesktopWindow() // Get handle to desktop window
llptr_hdc = GetDC(llptr_hwnd) // Get handle to desktop's device context
// 96 dots/inch is normal (100%), 120 is 125%, 144 is 150%
lul_dpi_x = GetDeviceCaps(llptr_hdc, LOGPIXELSX)
lul_dpi_y = GetDeviceCaps(llptr_hdc, LOGPIXELSY)
ll_percent = (lul_dpi_x * 100) / 96
ll_rc = ReleaseDC(llptr_hwnd, llptr_hdc) // Release the device context
// Script end ... BIG THANKYOU to John Fauss: https://community.appeon.com/index.php/qna/q-a/profile/2184-john-fauss
else
ll_percent = 100
end if
choose case true
case l_screenwidth >= ar_l_screen_width and l_screenheight >= ar_l_screen_height and ll_percent = 100
return true
case else
MessageBox(ar_s_window_title, 'Minimum resolution to run this screen is ' + string(ar_l_screen_width) + ' X ' + string(ar_l_screen_height) + '.~n~nYour monitor display settings are: ' + s_width + ' X ' + s_Height + &
'~n~nPlease readjust you monitor:~n Display Settings/Scale Layout to run this screen.', Exclamation!)
return false
end choose
end function
Third, just before opening window, in our case in the w_frame, i am passing minimum width (1920) and height (1080) to functions, so i can check if user can run this window:
if not f_check_display_settings(1920,1080,'My window title') then
return
else
// open window ...
end if
Hope it will help you at least for a start.
Scaling reset to 100% is a workaround but it has limited viability because it significantly reduces accessibility - and that itself can be issue.
Also, a 4K screen on 13.5 inch laptop with touch screen => Direct interaction on screen becomes a challenge when touch targets are just millimeter size and located next to each other. Again, accessibility suffers due to scaling issues.