WinWorkstation.st
changeset 8903 24bbd43fb28b
parent 8902 b9dae783c9ab
child 8904 4247707f2d27
--- a/WinWorkstation.st	Tue Nov 26 16:33:58 2019 +0100
+++ b/WinWorkstation.st	Tue Nov 26 16:43:54 2019 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
 COPYRIGHT (c) 1996 by Claus Gittinger
 	      All Rights Reserved
@@ -2149,7 +2151,7 @@
 		    }
 		    goto again;
 		}
-		/* fail evtl. später ändern und in st verzögert aufrufen
+		/* fail evtl. später ändern und in st verzögert aufrufen
 		*/
 		console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed.\n",(char*)ev->ev_arg1);
 	    }
@@ -6858,16 +6860,11 @@
      here we return 1, 1.25 1.5"
 
     "
-        Screen monitorScaleFactorFor:(Display monitorHandleForName:'\\.\DISPLAY1').   
-        Screen monitorScaleFactorFor:(Display monitorHandleForName:'\\.\DISPLAY2').   
-    "
-
-    |sx|
-
-    (aMonitorHandle isNil 
-    or:[aMonitorHandle isExternalAddress not]) ifTrue:[
-        ^ super monitorScaleFactorFor:aMonitorHandle
-    ].
+        Screen monitorScaleFactorFor:(Display monitorHandleForName:'\\.\DISPLAY1').     
+        Screen monitorScaleFactorFor:(Display monitorHandleForName:'\\.\DISPLAY2').     
+    "
+
+    |scaleFactor|
 
 %{
     if (__isExternalAddress(aMonitorHandle)) {
@@ -6875,20 +6872,19 @@
         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 = 0;
-                UINT y = 0;
-
-                if ((*P_GetDpiForMonitor)(hMonitor, 0, &x, &y) == S_OK) {
-                    sx = __MKSMALLINT(x);
+            static HRESULT (__stdcall *P_GetScaleFactorForMonitor)(HMONITOR, VOID*);
+            P_GetScaleFactorForMonitor = (HRESULT (__stdcall *)(HMONITOR, VOID*))GetProcAddress(hShcore, "GetScaleFactorForMonitor");
+
+            if (P_GetScaleFactorForMonitor) {
+                UINT displayScaleFactor = 0;
+
+                if ((*P_GetScaleFactorForMonitor)(hMonitor, &displayScaleFactor) == S_OK) {
+                    scaleFactor = __MKSMALLINT(displayScaleFactor);
                 } else {
-                    printf("Call \"GetDpiForMonitor()\" failed\n");
+                    printf("Call \"GetScaleFactorForMonitor()\" failed\n");
                 };      
             } else {
-                printf("Loading \"GetDpiForMonitor()\" failed\n");
+                printf("Loading \"GetScaleFactorForMonitor()\" failed\n");
             }
         } else {
             printf("Loading \"Shcore.dll\" failed\n");
@@ -6896,15 +6892,17 @@
     }
 %}.
 
-    (sx isNil 
-    or:[sx == 0]) ifTrue:[
+    scaleFactor isNil ifTrue:[
         ^ super monitorScaleFactorFor:aMonitorHandle
     ].
-
-    ^ sx / 96
+    scaleFactor == 0 ifTrue:[
+        ^ super monitorScaleFactorFor:aMonitorHandle
+    ].
+
+    ^ scaleFactor / 100
 
     "Created: / 25-11-2019 / 11:52:42 / Stefan Reise"
-    "Modified: / 26-11-2019 / 15:37:54 / Stefan Reise"
+    "Modified: / 26-11-2019 / 16:43:29 / Stefan Reise"
 !
 
 thisAppVirtualResolutionByMonitorDeviceName:aMonitorDeviceName
@@ -20566,7 +20564,7 @@
     }
 %}
     "
-     (StandardSystemView new label:'äöü') open
+     (StandardSystemView new label:'äöü') open
     "
 !