WinWorkstation.st
changeset 7601 32eb7cdadd8a
parent 7598 fa0cfb5cedc1
child 7602 f1afeef47a60
child 7605 102b25e1e61b
--- a/WinWorkstation.st	Fri Oct 07 16:58:05 2016 +0200
+++ b/WinWorkstation.st	Mon Oct 10 12:24:06 2016 +0200
@@ -18490,7 +18490,7 @@
     "
 !
 
-sendCopyData: aByteArray toWindowId: aWindowId
+sendCopyData: aByteArrayOrString toWindowId: aWindowId
     "send copy-paste data to a window by id (handle)"
 
     |externalBytes messageType lParam copyDataStruct|
@@ -18499,7 +18499,7 @@
 
     messageType := 74 "WM_COPYDATA".
 
-    externalBytes := aByteArray asExternalBytesUnprotected.
+    externalBytes := aByteArrayOrString asExternalBytesUnprotected.
     copyDataStruct := CopyDataStructStructure new.
     copyDataStruct 
         cbData:externalBytes size;
@@ -18508,33 +18508,21 @@
     ^ self primSendMessage:aWindowId message:messageType wParam:nil lParam:lParam.
 
     "
-     |bytes externalAddress handle|
+     |handle|
+     handle := Display primFindWindowA: nil windowName: 'expecco'.
+     (handle isNil or:[handle address == 0]) ifTrue:[self halt.].
+     Display sendCopyData: 'openPath: bla' toWindowId: handle.
+     Display setForegroundWindow: handle.
+    "
+
+    "
+     |bytes handle|
 
      bytes := 'c:\pipo.net' asByteArray.
      handle := Display primFindWindowA: nil windowName: 'ST/X Launcher'.
      (handle isNil or:[handle address == 0]) ifTrue:[self halt.].
-     externalAddress := handle asExternalAddress.
-     Display setForegroundWindow: externalAddress.
-     Display sendCopyData: bytes toWindowId: externalAddress.
-    "
-!
-
-sendCopyDataString: aString toWindowId: aWindowId
-    "send a string as copy-paste data to a window by id (handle)"
-
-    |aByteArray nullTerminatedString |
-
-    nullTerminatedString := aString , 0 asCharacter asString.
-    aByteArray := nullTerminatedString asByteArray.
-    self sendCopyData: aByteArray toWindowId: aWindowId
-
-    "
-     |externalAddress handle|
-     handle := Display primFindWindowA: nil windowName: 'Windows-Befehlsprozessor'.
-     (handle isNil or:[handle address == 0]) ifTrue:[self halt.].
-     externalAddress := handle asExternalAddress.
-     Display setForegroundWindow: externalAddress.
-     Display sendCopyDataString: 'c:\windows\notepad.exe' toWindowId: externalAddress.
+     Display setForegroundWindow: handle.
+     Display sendCopyData: bytes toWindowId: handle.
     "
 !
 
@@ -18615,18 +18603,7 @@
      a different process is currently active - in this case the title bar/icon is flashed.
      this also raises the priority of the sending thread slightly"
 
-%{  /* NOCONTEXT */
-    if (__isExternalAddress(aWindowId)) {
-	HWND win = _HWNDVal(aWindowId);
-
-	if (win) {
-	    CPRINTF(("setForegroundWindow %x\n",win));
-
-	    SetForegroundWindow(win);
-	}
-	RETURN ( self );
-    }
-%}
+    <apicall: bool "SetForegroundWindow" (handle) module: "user32.dll" >
 !
 
 setIconName:aString in:aWindowId
@@ -19286,16 +19263,17 @@
 
 cbData
     ExternalAddress pointerSize == 8 ifTrue:[
-        ^ self unsignedInt64At: 8 + 1.
+        ^ self unsignedInt32At: 8 + 1.
     ].
     ^ self unsignedInt32At: 4 + 1.
 !
 
 cbData: cbData
     ExternalAddress pointerSize == 8 ifTrue:[
-        ^ self unsignedInt64At: 8 + 1  put: cbData.
-    ].
-    ^ self unsignedInt32At: 4 + 1  put: cbData.
+        self unsignedInt32At: 8 + 1  put: cbData.
+    ] ifFalse:[
+        self unsignedInt32At: 4 + 1  put: cbData.
+    ].
 !
 
 dwData
@@ -19307,9 +19285,10 @@
 
 dwData: dwData
     ExternalAddress pointerSize == 8 ifTrue:[
-        ^ self unsignedInt64At: 0 + 1 put:dwData.
-    ].
-    ^ self unsignedInt32At: 0 + 1 put:dwData.
+        self unsignedInt64At: 0 + 1 put:dwData.
+    ] ifFalse:[
+        self unsignedInt32At: 0 + 1 put:dwData.
+    ].
 !
 
 lpData
@@ -19321,9 +19300,10 @@
 
 lpData: lpData
     ExternalAddress pointerSize == 8 ifTrue:[
-        ^ self unsignedInt64At: 12 + 1  put: lpData.
-    ].
-    ^ self unsignedInt32At: 8 + 1  put: lpData.
+        self unsignedInt64At: 12 + 1  put: lpData.
+    ] ifFalse:[
+        self unsignedInt32At: 8 + 1  put: lpData.
+    ].
 ! !
 
 !WinWorkstation::MonitorInfo methodsFor:'accessing'!