*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Fri, 15 Jun 2007 11:52:50 +0200
changeset 4792 59e34dfdfae7
parent 4791 68d25975161e
child 4793 d30d38703d4f
*** empty log message ***
WinWorkstation.st
--- a/WinWorkstation.st	Wed Jun 06 18:58:02 2007 +0200
+++ b/WinWorkstation.st	Fri Jun 15 11:52:50 2007 +0200
@@ -9,8 +9,6 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
-'From Smalltalk/X, Version:5.3.5 on 04-04-2007 at 15:55:25'                     !
-
 "{ Package: 'stx:libview' }"
 
 DeviceWorkstation subclass:#WinWorkstation
@@ -15736,23 +15734,65 @@
 
 !WinWorkstation methodsFor:'window stuff'!
 
-activateWindow:aWindowId
+activateWindow1:aWindowId
     "make a window active (so that it gets the focus)"
 
 %{  /* NOCONTEXT */
     if (__isExternalAddress(aWindowId)) {
-	HWND win = _HWNDVal(aWindowId);
-
-	if (win) {
-	    CPRINTF(("activateWindow %x\n",win));
+        HWND win = _HWNDVal(aWindowId);
+
+        if (win) {
+            CPRINTF(("activateWindow %x\n",win));
 #if 0
-	    ShowWindowAsync(win, SW_SHOW);
-#else
-	    ShowWindow(win, SW_SHOW);
-#endif
-	}
-    }
-%}
+            ShowWindowAsync(win, SW_SHOW);
+#else
+            ShowWindow(win, SW_SHOW);
+#endif
+        }
+    }
+%}
+!
+
+activateWindow2:aWindowId
+    "make a window active (so that it gets the focus).
+     Paranoid implementation."
+
+%{  /* NOCONTEXT */
+    if (__isExternalAddress(aWindowId)) {
+        HWND win = _HWNDVal(aWindowId);
+
+        if (win) {
+            DWORD activeThreadID, activeProcessID;
+            DWORD myThreadID;
+            HWND foregroundWindow = GetForegroundWindow();
+
+            if (foregroundWindow) {
+                activeThreadID = GetWindowThreadProcessId(foregroundWindow, &activeProcessID);
+                myThreadID = GetCurrentThreadId();
+                AttachThreadInput(activeThreadID, myThreadID, TRUE);
+            }
+
+            // Do our stuff here ;-)
+            ShowWindow(win, SW_SHOW);
+            SetForegroundWindow(win);
+            SetFocus(win);
+
+            if (foregroundWindow) {
+                AttachThreadInput(activeThreadID, myThreadID, FALSE);
+            }
+        }
+    }
+%}
+!
+
+activateWindow:aWindowId
+    "make a window active (so that it gets the focus)"
+
+    "/ on some systems I seem to not get thje window to be raised with focus.
+    "/ we might try activate2 there.
+
+    self activateWindow1:aWindowId
+    "/ self activateWindow2:aWindowId
 !
 
 animateWindow:aWindowId show:doShow animation:animationSymbolorNil time:timeInMillisOrNil
@@ -16335,17 +16375,17 @@
 %{  /* NOCONTEXT */
 
     if (__isExternalAddress(aWindowId)) {
-	HWND hWnd = _HWNDVal(aWindowId);
-
-	if (hWnd) {
-	    CPRINTF(("raiseWindow %x\n",hWnd));
-	    SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
-			 /* SWP_NOOWNERZORDER |*/
-			 SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+        HWND hWnd = _HWNDVal(aWindowId);
+
+        if (hWnd) {
+            CPRINTF(("raiseWindow %x\n",hWnd));
+            SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
+                         /* SWP_NOOWNERZORDER |*/
+                         SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
 #if 0
-	    BringWindowToTop(hWnd);
-#endif
-	}
+            BringWindowToTop(hWnd);
+#endif
+        }
     }
 %}
 !
@@ -17053,7 +17093,7 @@
 !WinWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.342 2007-04-04 14:18:07 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.343 2007-06-15 09:52:50 cg Exp $'
 ! !
 
 WinWorkstation initialize!