WinWorkstation.st
changeset 8888 3314cdb1cb9a
parent 8887 341943f4a94f
child 8890 cb7a6221f06c
--- a/WinWorkstation.st	Mon Nov 25 10:04:14 2019 +0100
+++ b/WinWorkstation.st	Mon Nov 25 11:20:33 2019 +0100
@@ -8435,6 +8435,42 @@
     "Created: / 21-11-2019 / 13:35:22 / Stefan Reise"
 !
 
+monitorScalingFactorFor:aMonitorHandle
+    "
+        Display monitorScalingFactorFor:(Display monitorHandleForName:'\\.\DISPLAY1').     
+        Display monitorScalingFactorFor:(Display monitorHandleForName:'\\.\DISPLAY2').    
+    "
+
+%{
+    if (__isExternalAddress(aMonitorHandle)) {
+        HMONITOR hMonitor = (HMONITOR)(_HWNDVal(aMonitorHandle));
+        HINSTANCE hShcore = LoadLibrary("Shcore.dll");
+
+        if (hShcore) {
+            static HRESULT (__stdcall *P_GetDpiForMonitor)(HMONITOR, DWORD, UINT, UINT);
+            P_GetDpiForMonitor = (HRESULT (__stdcall *)(HMONITOR, DWORD, UINT, UINT)) GetProcAddress(hShcore, "GetDpiForMonitor");
+
+            if (P_GetDpiForMonitor) {
+                UINT x;
+                UINT y;               
+
+                if ((*P_GetDpiForMonitor)(hMonitor, 0 /* 0 | 1 | 2 */, &x, &y) == S_OK) {
+                    printf("%d@%d\n", x, y);
+                } else {
+                    printf("Call \"GetDpiForMonitor()\" failed\n");
+                };
+            } else {
+                printf("Loading \"GetDpiForMonitor()\" failed\n");
+            }
+        } else {
+            printf("Loading \"Shcore.dll\" failed\n");
+        }
+    }
+%}
+
+    "Created: / 25-11-2019 / 11:17:48 / Stefan Reise"
+!
+
 numberOfMonitors
     ^ self getSystemMetrics:#SM_CMONITORS