Index: trunk/src/user32/oslibwin.cpp
===================================================================
--- trunk/src/user32/oslibwin.cpp	(revision 1838)
+++ trunk/src/user32/oslibwin.cpp	(revision 1839)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.cpp,v 1.47 1999-11-24 19:32:21 sandervl Exp $ */
+/* $Id: oslibwin.cpp,v 1.48 1999-11-25 19:22:02 sandervl Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -38,5 +38,8 @@
         hwndParent = HWND_DESKTOP;
   }
-
+  else
+  if(hwndParent == OSLIB_HWND_OBJECT) {
+        hwndParent = HWND_OBJECT;
+  }
   return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
 }
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 1838)
+++ trunk/src/user32/win32wbase.cpp	(revision 1839)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.94 1999-11-24 20:28:20 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.95 1999-11-25 19:22:02 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -634,5 +634,4 @@
   else
   {
-        dprintf(("Set window ID to %x", cs->hMenu));
         setWindowId((DWORD)cs->hMenu);
   }
@@ -1544,10 +1543,15 @@
 
     case WM_SETREDRAW:
+    {
+     DWORD oldStyle = getStyle();
+
         if(wParam)
-                SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE);
-        else    SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);
+                setStyle(getStyle() | WS_VISIBLE);
+        else    setStyle(getStyle() & ~WS_VISIBLE);
+
+        updateWindowStyle(getExStyle(), oldStyle);
 
         return 0; //TODO
-
+    }
     case WM_NCCREATE:
         return(TRUE);
@@ -2068,36 +2072,83 @@
 }
 //******************************************************************************
-//TODO: Probably not complete compatible with win32 implementation
-//******************************************************************************
-LRESULT Win32BaseWindow::BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam)
+//Send message to window of another process
+//******************************************************************************
+LRESULT Win32BaseWindow::SendMessageToProcess(UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
 {
  POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
 
-    dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam));
-    return 0;
-
+    dprintf(("SendMessageToProcess %x %x %x %x", getOS2WindowHandle(), msg, wParam, lParam));
     packet->Msg = msg;
     packet->wParam = wParam;
     packet->lParam = lParam;
-    packet->fUnicode = FALSE;
-
-    return OSLibWinBroadcastMsg(WIN32APP_POSTMSG, WIN32PM_MAGIC, (DWORD)packet, type == BROADCAST_SEND);
-}
-//******************************************************************************
-//TODO: Probably not complete compatible with win32 implementation
+    packet->fUnicode = fUnicode;
+    return OSLibSendMessage(getOS2WindowHandle(), WIN32APP_POSTMSG, WIN32PM_MAGIC, (DWORD)packet);
+}
+//******************************************************************************
+//TODO: Do this more efficiently
+//******************************************************************************
+LRESULT Win32BaseWindow::BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ Win32BaseWindow *window;
+ HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
+ DWORD processid, myprocessid;
+
+    dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam, GetFS()));
+    myprocessid = GetCurrentProcessId();
+
+    for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
+        window = GetWindowFromHandle(hwnd++);
+        if(window) {
+            if (window->getStyle() & WS_POPUP || (window->getStyle() & WS_CAPTION) == WS_CAPTION)
+            {
+
+                if(type == BROADCAST_SEND) {
+                        GetWindowThreadProcessId(hwnd, &processid);
+                        if(processid == myprocessid) {
+                            window->SendMessageA(msg, wParam, lParam);
+                        }
+                        else {
+                            window->SendMessageToProcess(msg, wParam, lParam, FALSE);
+                        }
+                }
+                else    window->PostMessageA(msg, wParam, lParam);
+            }
+        }
+    }
+    return 0;
+}
+//******************************************************************************
+//TODO: Do this more efficiently
 //******************************************************************************
 LRESULT Win32BaseWindow::BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam)
 {
- POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
+ Win32BaseWindow *window;
+ HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
+ DWORD processid, myprocessid;
+
 
     dprintf(("BroadCastMessageW %x %x %x", msg, wParam, lParam));
+    myprocessid = GetCurrentProcessId();
+
+    for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
+        window = GetWindowFromHandle(hwnd++);
+        if(window) {
+            if (window->getStyle() & WS_POPUP || (window->getStyle() & WS_CAPTION) == WS_CAPTION)
+            {
+
+                if(type == BROADCAST_SEND) {
+                        GetWindowThreadProcessId(hwnd, &processid);
+                        if(processid == myprocessid) {
+                            window->SendMessageW(msg, wParam, lParam);
+                        }
+                        else {
+                            window->SendMessageToProcess(msg, wParam, lParam, TRUE);
+                        }
+                }
+                else    window->PostMessageW(msg, wParam, lParam);
+            }
+        }
+    }
     return 0;
-
-    packet->Msg = msg;
-    packet->wParam = wParam;
-    packet->lParam = lParam;
-    packet->fUnicode = TRUE;
-
-    return OSLibWinBroadcastMsg(WIN32APP_POSTMSG, WIN32PM_MAGIC, (DWORD)packet, type == BROADCAST_SEND);
 }
 //******************************************************************************
@@ -2403,6 +2454,10 @@
         return oldhwnd;
    }
-   SetLastError(ERROR_INVALID_PARAMETER);
-   return 0;
+   else {
+    setParent(windowDesktop);
+        getParent()->AddChild(this);
+        OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
+        return oldhwnd;
+   }
 }
 //******************************************************************************
@@ -2814,5 +2869,5 @@
                 SendMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
                 setExStyle(ss.styleNew);
-                updateWindowStyle(ss.styleOld,dwStyle);
+                updateWindowStyle(ss.styleOld,getStyle());
                 SendMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
                 return ss.styleOld;
@@ -2825,11 +2880,15 @@
                     return value;
 
-                ss.styleOld = dwStyle;
-                ss.styleNew = value;
-                dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), dwStyle, value));
+		        value &= ~(WS_VISIBLE | WS_CHILD);	/* Some bits can't be changed this way (WINE) */
+                ss.styleOld = getStyle();
+		        ss.styleNew = value | (ss.styleOld & (WS_VISIBLE | WS_CHILD));
+                dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), getStyle(), value));
                 SendMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
                 setStyle(ss.styleNew);
                 updateWindowStyle(dwExStyle,ss.styleOld);
                 SendMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
+#ifdef DEBUG
+                PrintWindowStyle(ss.styleNew, 0);
+#endif
                 return ss.styleOld;
         }
@@ -2937,4 +2996,5 @@
 {
     windowId = id;
+    dprintf(("Set window ID to %x", id));
     OSLibSetWindowID(OS2HwndFrame, id);
 }
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 1838)
+++ trunk/src/user32/win32wbase.h	(revision 1839)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.45 1999-11-24 19:32:23 sandervl Exp $ */
+/* $Id: win32wbase.h,v 1.46 1999-11-25 19:22:03 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -207,4 +207,5 @@
        LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
        LRESULT  SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
+       LRESULT  SendMessageToProcess(UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode);
        BOOL     PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
        BOOL     PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
Index: trunk/src/user32/win32wndhandle.cpp
===================================================================
--- trunk/src/user32/win32wndhandle.cpp	(revision 1838)
+++ trunk/src/user32/win32wndhandle.cpp	(revision 1839)
@@ -1,3 +1,3 @@
-/* $Id: win32wndhandle.cpp,v 1.1 1999-09-15 23:19:02 sandervl Exp $ */
+/* $Id: win32wndhandle.cpp,v 1.2 1999-11-25 19:22:03 sandervl Exp $ */
 /*
  * Win32 Handle Management Code for OS/2
@@ -19,8 +19,4 @@
 #include <vmutex.h>
 #include "win32wndhandle.h"
-
-#define MAX_WINDOW_HANDLES	 1024
-#define WNDHANDLE_MAGIC_HIGHWORD 0x68000000
-#define WNDHANDLE_MAGIC_MASK     0x0000FFFF
 
 //******************************************************************************
Index: trunk/src/user32/win32wndhandle.h
===================================================================
--- trunk/src/user32/win32wndhandle.h	(revision 1838)
+++ trunk/src/user32/win32wndhandle.h	(revision 1839)
@@ -1,3 +1,3 @@
-/* $Id: win32wndhandle.h,v 1.1 1999-09-15 23:19:02 sandervl Exp $ */
+/* $Id: win32wndhandle.h,v 1.2 1999-11-25 19:22:04 sandervl Exp $ */
 /*
  * Win32 Handle Management Code for OS/2
@@ -13,4 +13,8 @@
 #define __WIN32WNDHANDLE_H__
 
+#define MAX_WINDOW_HANDLES	 1024
+#define WNDHANDLE_MAGIC_HIGHWORD 0x68000000
+#define WNDHANDLE_MAGIC_MASK     0x0000FFFF
+
 BOOL  HwAllocateWindowHandle(HWND *hwnd, DWORD dwUserData);
 void  HwFreeWindowHandle(HWND hwnd);
Index: trunk/src/user32/windlg.cpp
===================================================================
--- trunk/src/user32/windlg.cpp	(revision 1838)
+++ trunk/src/user32/windlg.cpp	(revision 1839)
@@ -1,3 +1,3 @@
-/* $Id: windlg.cpp,v 1.11 1999-11-05 17:50:30 achimha Exp $ */
+/* $Id: windlg.cpp,v 1.12 1999-11-25 19:22:04 sandervl Exp $ */
 /*
  * Win32 dialog apis for OS/2
@@ -130,4 +130,5 @@
         if(!dialog || !dialog->IsDialog()) {
             dprintf(("DialogBoxIndirectParamA, dialog %x not found", hwnd));
+    	    SetLastError(ERROR_INVALID_WINDOW_HANDLE);
             return 0;
         }
@@ -151,4 +152,5 @@
         if(!dialog || !dialog->IsDialog()) {
             dprintf(("DialogBoxIndirectParamW, dialog %x not found", hwnd));
+    	    SetLastError(ERROR_INVALID_WINDOW_HANDLE);
             return 0;
         }
@@ -171,4 +173,5 @@
         if(!dialog || !dialog->IsDialog()) {
             dprintf(("DialogBoxParamA, dialog %x not found", hwnd));
+    	    SetLastError(ERROR_INVALID_WINDOW_HANDLE);
             return 0;
         }
@@ -191,4 +194,5 @@
         if(!dialog || !dialog->IsDialog()) {
             dprintf(("DialogBoxParamW, dialog %x not found", hwnd));
+    	    SetLastError(ERROR_INVALID_WINDOW_HANDLE);
             return 0;
         }
@@ -255,4 +259,5 @@
     }
     dprintf(("USER32: GetDlgItem %x %d NOT FOUND!\n", hwnd, id));
+    SetLastError(ERROR_INVALID_PARAMETER);
     return 0;
 }
Index: trunk/src/user32/window.cpp
===================================================================
--- trunk/src/user32/window.cpp	(revision 1838)
+++ trunk/src/user32/window.cpp	(revision 1839)
@@ -1,3 +1,3 @@
-/* $Id: window.cpp,v 1.37 1999-11-21 16:22:14 achimha Exp $ */
+/* $Id: window.cpp,v 1.38 1999-11-25 19:22:04 sandervl Exp $ */
 /*
  * Win32 window apis for OS/2
@@ -1120,5 +1120,5 @@
     pDWP = (DWP *) hdwp;
     if (!pDWP) {
-    dprintf(("**EndDeferWindowPos invalid parameter\n"));
+    	dprintf(("**EndDeferWindowPos invalid parameter\n"));
         SetLastError(ERROR_INVALID_PARAMETER);
         return FALSE;
@@ -1462,5 +1462,5 @@
 DWORD WIN32API GetWindowThreadProcessId(HWND hWnd, PDWORD  lpdwProcessId)
 {
-    dprintf(("USER32:  GetWindowThreadProcessId"));
+    dprintf2(("USER32:  GetWindowThreadProcessId"));
     hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
 
@@ -1471,8 +1471,14 @@
 DWORD WIN32API GetWindowContextHelpId(HWND hwnd)
 {
-  dprintf(("USER32:  GetWindowContextHelpId, not implemented\n"));
-  hwnd = Win32BaseWindow::Win32ToOS2Handle(hwnd);
-
-  return(0);
+  Win32BaseWindow *window;
+
+    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
+    if(!window) {
+        dprintf(("GetWindowContextHelpId, window %x not found", hwnd));
+        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
+        return 0;
+    }
+    dprintf(("GetWindowContextHelpId %x", hwnd));
+    return window->getWindowContextHelpId();
 }
 //******************************************************************************
@@ -1480,9 +1486,16 @@
 BOOL WIN32API SetWindowContextHelpId(HWND hwnd, DWORD dwContextHelpId)
 {
-  dprintf(("USER32:  SetWindowContextHelpId, not implemented"));
-  hwnd = Win32BaseWindow::Win32ToOS2Handle(hwnd);
-
-  return(TRUE);
-}
-//******************************************************************************
-//******************************************************************************
+  Win32BaseWindow *window;
+
+    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
+    if(!window) {
+        dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
+        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
+        return 0;
+    }
+    dprintf(("SetWindowContextHelpId %x %d", hwnd, dwContextHelpId));
+    window->setWindowContextHelpId(dwContextHelpId);
+    return(TRUE);
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/user32/windowword.cpp
===================================================================
--- trunk/src/user32/windowword.cpp	(revision 1838)
+++ trunk/src/user32/windowword.cpp	(revision 1839)
@@ -1,3 +1,3 @@
-/* $Id: windowword.cpp,v 1.3 1999-11-11 13:17:33 sandervl Exp $ */
+/* $Id: windowword.cpp,v 1.4 1999-11-25 19:22:04 sandervl Exp $ */
 
 /*
@@ -138,5 +138,5 @@
     else
     {
-        dprintf(("GetWindowLongA; window %x not found!", hwnd));
+        dprintf(("GetWindowLongA; window %x (%d) not found!", hwnd, nIndex));
     }
     return 0;
