there are different Way to get Scale-Factor.
for single Monitor you can use "real" / "virtual" Desktop Size to get Scale-Factor
- Code: Select all Expand view
- #define HORZRES 0x0008 // ( 8) Horizontal width in pixels
#define VERTRES 0x000A // ( 10) Vertical width in pixels
#define LOGPIXELSX 0x0058 // ( 88) Logical pixels/inch in X
#define LOGPIXELSY 0x005A // ( 90) Logical pixels/inch in Y
#define DESKTOPVERTRES 0x0075 // (117) Vertical height of entire desktop in pixels
#define DESKTOPHORZRES 0x0076 // (118) Horizontal width of entire desktop in pixels
Function GetDeskSize(nHDC,lVirtual)
LOCAL nWidth,nHeight
nWidth := HMG_CallDLL('GDI32.dll', DLL_OSAPI, 'GetDeviceCaps', nHDC, iif(lVirtual, HORZRES, DESKTOPHORZRES))
nHeight := HMG_CallDLL('GDI32.dll', DLL_OSAPI, 'GetDeviceCaps', nHDC, iif(lVirtual, VERTRES, DESKTOPVERTRES))
RETURN{nWidth,nHeight}
---
for multi-Monitor you need
MonitorFromWindow https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfromwindow
GetScaleFactorForMonitor https://docs.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getscalefactorformonitor
DEVICE_SCALE_FACTOR https://docs.microsoft.com/en-us/windows/win32/api/shtypes/ne-shtypes-device_scale_factor
GetScaleFactorForDevice is IMHO outdate
https://docs.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getscalefactorfordevice