Index: trunk/src/user32/new/oslibmsg.cpp
===================================================================
--- trunk/src/user32/new/oslibmsg.cpp	(revision 2311)
+++ trunk/src/user32/new/oslibmsg.cpp	(revision 2312)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsg.cpp,v 1.6 2000-01-01 14:57:18 cbratschi Exp $ */
+/* $Id: oslibmsg.cpp,v 1.7 2000-01-03 21:37:17 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -178,6 +178,11 @@
             thdb->msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
             memcpy(&thdb->msg, msg, sizeof(MSG));
-        }
-        return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
+	    return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
+        }
+	//SvL: TODO; What to do if messages posted by PostThreadMessage are
+        //     dispatched? Wine doesn't appear to do this.
+        //     If we call WinDispatchMsg, every window created by the thread
+        //     receives this message. Does this also happen in NT?
+        return 0;
   }
   else {//is this allowed?
@@ -193,4 +198,5 @@
  BOOL rc, eaten;
  THDB *thdb;
+ QMSG  os2msg;
 
   thdb = GetThreadTHDB();
@@ -223,4 +229,6 @@
         }
         while(rc == FALSE);
+
+	return rc;
   }
   else
@@ -228,10 +236,13 @@
     do {
         eaten = FALSE;
-        rc = WinGetMsg(thdb->hab, MsgThreadPtr, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
-        if (MsgThreadPtr->msg == WM_TIMER)
-            eaten = TIMER_HandleTimer (MsgThreadPtr);
+        rc = WinGetMsg(thdb->hab, &os2msg, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
+        if (os2msg.msg == WM_TIMER)
+            eaten = TIMER_HandleTimer(&os2msg);
     } while (eaten);
   }
-  OS2ToWinMsgTranslate((PVOID)thdb, MsgThreadPtr, pMsg, isUnicode, MSG_REMOVE);
+  if(rc) {
+	OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, MSG_REMOVE);
+        memcpy(MsgThreadPtr, &os2msg, sizeof(QMSG));
+  }
   return rc;
 }
@@ -393,21 +404,33 @@
 }
 //******************************************************************************
+BOOL    _System _O32_PostThreadMessage( DWORD, UINT, WPARAM, LPARAM );
+
+inline BOOL O32_PostThreadMessage(DWORD a, UINT b, WPARAM c, LPARAM d)
+{
+ BOOL yyrc;
+ USHORT sel = RestoreOS2FS();
+
+    yyrc = _O32_PostThreadMessage(a, b, c, d);
+    SetFS(sel);
+
+    return yyrc;
+} 
 //******************************************************************************
 BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
 {
- THDB *thdb = GetTHDBFromThreadId(threadid);
+// THDB *thdb = GetTHDBFromThreadId(threadid);
  POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
 
-    if(thdb == NULL) {
-        dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
-        return FALSE;
-    }
+//    if(thdb == NULL) {
+//        dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
+//        return FALSE;
+//    }
     dprintf(("PostThreadMessageA %x %x %x %x", threadid, msg, wParam, lParam));
     packet->Msg = msg;
     packet->wParam = wParam;
     packet->lParam = lParam;
-    return WinPostQueueMsg(thdb->hmq, WIN32APP_POSTMSG, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
-}
-//******************************************************************************
-//******************************************************************************
-
+    return _O32_PostThreadMessage(threadid, WIN32APP_POSTMSG-OPEN32_MSGDIFF, ((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (LPARAM)packet);
+}
+//******************************************************************************
+//******************************************************************************
+
Index: trunk/src/user32/new/win32wbase.h
===================================================================
--- trunk/src/user32/new/win32wbase.h	(revision 2311)
+++ trunk/src/user32/new/win32wbase.h	(revision 2312)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.15 2000-01-02 20:20:03 sandervl Exp $ */
+/* $Id: win32wbase.h,v 1.16 2000-01-03 21:37:17 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -39,6 +39,9 @@
 } CUSTOMWNDDATA;
 
-#define WIN32APP_USERMSGBASE      0x1000
-#define WIN32APP_POSTMSG          0x1000
+//PostThreadMessage is done through Open32; which means the message id will be translated
+//(0xc00 added)
+#define OPEN32_MSGDIFF		  0xC00
+#define WIN32APP_POSTMSG          (0x1000+OPEN32_MSGDIFF)
+
 #define WIN32MSG_MAGICA           0x12345678
 #define WIN32MSG_MAGICW           0x12345679
Index: trunk/src/user32/oslibmsg.cpp
===================================================================
--- trunk/src/user32/oslibmsg.cpp	(revision 2311)
+++ trunk/src/user32/oslibmsg.cpp	(revision 2312)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsg.cpp,v 1.19 1999-12-29 22:54:00 cbratschi Exp $ */
+/* $Id: oslibmsg.cpp,v 1.20 2000-01-03 21:37:16 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -178,6 +178,11 @@
             thdb->msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
             memcpy(&thdb->msg, msg, sizeof(MSG));
-        }
-        return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
+	    return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
+        }
+	//SvL: TODO; What to do if messages posted by PostThreadMessage are
+        //     dispatched? Wine doesn't appear to do this.
+        //     If we call WinDispatchMsg, every window created by the thread
+        //     receives this message. Does this also happen in NT?
+        return 0;
   }
   else {//is this allowed?
@@ -193,4 +198,5 @@
  BOOL rc, eaten;
  THDB *thdb;
+ QMSG  os2msg;
 
   thdb = GetThreadTHDB();
@@ -223,4 +229,6 @@
         }
         while(rc == FALSE);
+
+	return rc;
   }
   else
@@ -228,10 +236,13 @@
     do {
         eaten = FALSE;
-        rc = WinGetMsg(thdb->hab, MsgThreadPtr, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
-        if (MsgThreadPtr->msg == WM_TIMER)
-            eaten = TIMER_HandleTimer (MsgThreadPtr);
+        rc = WinGetMsg(thdb->hab, &os2msg, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
+        if (os2msg.msg == WM_TIMER)
+            eaten = TIMER_HandleTimer(&os2msg);
     } while (eaten);
   }
-  OS2ToWinMsgTranslate((PVOID)thdb, MsgThreadPtr, pMsg, isUnicode, MSG_REMOVE);
+  if(rc) {
+	OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, MSG_REMOVE);
+        memcpy(MsgThreadPtr, &os2msg, sizeof(QMSG));
+  }
   return rc;
 }
@@ -393,21 +404,33 @@
 }
 //******************************************************************************
+BOOL    _System _O32_PostThreadMessage( DWORD, UINT, WPARAM, LPARAM );
+
+inline BOOL O32_PostThreadMessage(DWORD a, UINT b, WPARAM c, LPARAM d)
+{
+ BOOL yyrc;
+ USHORT sel = RestoreOS2FS();
+
+    yyrc = _O32_PostThreadMessage(a, b, c, d);
+    SetFS(sel);
+
+    return yyrc;
+} 
 //******************************************************************************
 BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
 {
- THDB *thdb = GetTHDBFromThreadId(threadid);
+// THDB *thdb = GetTHDBFromThreadId(threadid);
  POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
 
-    if(thdb == NULL) {
-        dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
-        return FALSE;
-    }
+//    if(thdb == NULL) {
+//        dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
+//        return FALSE;
+//    }
     dprintf(("PostThreadMessageA %x %x %x %x", threadid, msg, wParam, lParam));
     packet->Msg = msg;
     packet->wParam = wParam;
     packet->lParam = lParam;
-    return WinPostQueueMsg(thdb->hmq, WIN32APP_POSTMSG, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
-}
-//******************************************************************************
-//******************************************************************************
-
+    return _O32_PostThreadMessage(threadid, WIN32APP_POSTMSG-OPEN32_MSGDIFF, ((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (LPARAM)packet);
+}
+//******************************************************************************
+//******************************************************************************
+
Index: trunk/src/user32/oslibmsgtranslate.cpp
===================================================================
--- trunk/src/user32/oslibmsgtranslate.cpp	(revision 2311)
+++ trunk/src/user32/oslibmsgtranslate.cpp	(revision 2312)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsgtranslate.cpp,v 1.6 1999-12-29 22:54:01 cbratschi Exp $ */
+/* $Id: oslibmsgtranslate.cpp,v 1.7 2000-01-03 21:37:16 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -132,5 +132,6 @@
             winMsg->wParam  = packet->wParam;
             winMsg->lParam  = packet->lParam;
-            if(fMsgRemoved == MSG_REMOVE) free(packet); //free the shared memory here
+            if(fMsgRemoved == MSG_REMOVE) 
+		free(packet); //free the shared memory here
             break;
         }
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 2311)
+++ trunk/src/user32/win32wbase.h	(revision 2312)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.65 2000-01-02 20:30:22 sandervl Exp $ */
+/* $Id: win32wbase.h,v 1.66 2000-01-03 21:37:17 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -39,6 +39,9 @@
 } CUSTOMWNDDATA;
 
-#define WIN32APP_USERMSGBASE      0x1000
-#define WIN32APP_POSTMSG          0x1000
+//PostThreadMessage is done through Open32; which means the message id will be translated
+//(0xc00 added)
+#define OPEN32_MSGDIFF		  0xC00
+#define WIN32APP_POSTMSG          (0x1000+OPEN32_MSGDIFF)
+
 #define WIN32MSG_MAGICA           0x12345678
 #define WIN32MSG_MAGICW           0x12345679
