WinWorkstation.st
changeset 8872 7d7024512b49
parent 8871 62717b04953b
child 8877 d12c092cd6ae
--- a/WinWorkstation.st	Tue Nov 19 12:19:46 2019 +0100
+++ b/WinWorkstation.st	Wed Nov 20 14:59:55 2019 +0100
@@ -16076,6 +16076,35 @@
 %}
 !
 
+monitorDeviceNameForView:aWindowId
+    "given a window ID, return its monitor device name or nil if failed"
+
+    "
+        Screen current monitorDeviceNameForView:Transcript topView id    
+    "          
+
+%{
+    if (__isExternalAddress(aWindowId)) {
+        HMONITOR hMonitor;
+        MONITORINFOEX monitorInfo;
+
+        hMonitor = MonitorFromWindow(_HWNDVal(aWindowId), MONITOR_DEFAULTTOPRIMARY);
+        if (hMonitor == 0) {
+            RETURN(nil);
+        }
+
+        monitorInfo.cbSize = sizeof(MONITORINFOEX);
+        if (GetMonitorInfo(hMonitor, &monitorInfo) == 0){
+            RETURN(nil);
+        }              
+
+        RETURN(__MKSTRING(monitorInfo.szDevice));
+    }
+%}
+
+    "Created: / 20-11-2019 / 14:52:59 / Stefan Reise"
+!
+
 monitorHandleForPoint:aPoint
     "given a point, return a handle to the monitor"
 
@@ -16128,31 +16157,31 @@
 
 %{
     if (__isExternalAddress(aWindowId)) {
-	HWND hWnd = _HWNDVal(aWindowId);
-	HMONITOR hMonitor;
-#if 0
-	/* the following is only needed when we want
-	 * to support very old NT/W95/W98 systems; we don't !
-	 */
-	static HMONITOR (__stdcall *P_MonitorFromWindow)(HWND, int);
-
-	if (P_MonitorFromWindow == 0) {
-	    HINSTANCE hUser = LoadLibrary("user32.dll");
-	    // console_printf("hUser: %x\n", hUser);
-	    if (hUser) {
-		P_MonitorFromWindow = (HMONITOR (__stdcall *)(HWND, int ))
-				    GetProcAddress(hUser, "MonitorFromWindow");
-	    }
-	}
-	// console_printf("P_MonitorFromWindow: %x\n", P_MonitorFromWindow);
-	hMonitor = (*P_MonitorFromWindow)(hWnd, MONITOR_DEFAULTTONULL);
-#else
-	hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
-#endif
-	if (hMonitor == 0) {
-	    RETURN(nil);
-	}
-	RETURN ( __MKEXTERNALADDRESS(hMonitor) );
+        HWND hWnd = _HWNDVal(aWindowId);
+        HMONITOR hMonitor;
+#if 0
+        /* the following is only needed when we want
+         * to support very old NT/W95/W98 systems; we don't !
+         */
+        static HMONITOR (__stdcall *P_MonitorFromWindow)(HWND, int);
+
+        if (P_MonitorFromWindow == 0) {
+            HINSTANCE hUser = LoadLibrary("user32.dll");
+            // console_printf("hUser: %x\n", hUser);
+            if (hUser) {
+                P_MonitorFromWindow = (HMONITOR (__stdcall *)(HWND, int ))
+                                    GetProcAddress(hUser, "MonitorFromWindow");
+            }
+        }
+        // console_printf("P_MonitorFromWindow: %x\n", P_MonitorFromWindow);
+        hMonitor = (*P_MonitorFromWindow)(hWnd, MONITOR_DEFAULTTONULL);
+#else
+        hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
+#endif
+        if (hMonitor == 0) {
+            RETURN(nil);
+        }
+        RETURN ( __MKEXTERNALADDRESS(hMonitor) );
     }
 %}
     "