Index: trunk/src/user32/new/makefile
===================================================================
--- trunk/src/user32/new/makefile	(revision 313)
+++ trunk/src/user32/new/makefile	(revision 314)
@@ -1,3 +1,3 @@
-# $Id: makefile,v 1.2 1999-07-15 18:03:01 sandervl Exp $
+# $Id: makefile,v 1.3 1999-07-16 11:32:08 sandervl Exp $
 
 #
@@ -28,5 +28,5 @@
         pmwindow.obj win32class.obj win32wnd.obj win32dlg.obj \
  	msgbox.obj window.obj windowmsg.obj windowclass.obj windlgmsg.obj \
-        windowword.obj gen_object.obj oslibwin.obj 
+        windowword.obj gen_object.obj oslibwin.obj win32wndchild.obj
 
 
@@ -67,14 +67,15 @@
 
 msgbox.obj:    msgbox.cpp
-window.obj:    window.cpp win32class.h win32wnd.h
-windowmsg.obj: windowmsg.cpp win32class.h win32wnd.h
-windlgmsg.obj: windlgmsg.cpp win32class.h win32wnd.h win32dlg.h
-windowclass.obj: windowclass.cpp win32class.h win32wnd.h
-windowword.obj:  windowword.cpp win32class.h win32wnd.h win32dlg.h
+window.obj:    window.cpp win32class.h win32wnd.h win32wndchild.h
+windowmsg.obj: windowmsg.cpp win32class.h win32wnd.h win32wndchild.h
+windlgmsg.obj: windlgmsg.cpp win32class.h win32wnd.h win32dlg.h win32wndchild.h
+windowclass.obj: windowclass.cpp win32class.h win32wnd.h win32wndchild.h
+windowword.obj:  windowword.cpp win32class.h win32wnd.h win32dlg.h win32wndchild.h
 
-pmwindow.obj:   pmwindow.cpp win32class.h win32wnd.h win32dlg.h pmwindow.h
-win32class.obj: win32class.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h
-win32wnd.obj:   win32wnd.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h
-win32dlg.obj:   win32dlg.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h
+pmwindow.obj:   pmwindow.cpp win32class.h win32wnd.h win32dlg.h pmwindow.h win32wndchild.h
+win32class.obj: win32class.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
+win32wnd.obj:   win32wnd.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
+win32dlg.obj:   win32dlg.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
+win32wndchild.obj: win32wndchild.cpp win32wndchild.h
 gen_object.obj: gen_object.cpp gen_object.h
 oslibwin.obj:   oslibwin.cpp oslibwin.h
Index: trunk/src/user32/new/oslibwin.cpp
===================================================================
--- trunk/src/user32/new/oslibwin.cpp	(revision 313)
+++ trunk/src/user32/new/oslibwin.cpp	(revision 314)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.cpp,v 1.3 1999-07-15 18:03:02 sandervl Exp $ */
+/* $Id: oslibwin.cpp,v 1.4 1999-07-16 11:32:08 sandervl Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -131,3 +131,14 @@
 //******************************************************************************
 //******************************************************************************
-
+HWND OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate)
+{
+  return WinCreateMenu(hwndParent, menutemplate);
+}
+//******************************************************************************
+//******************************************************************************
+HWND OSLibWinQueryTopMostChildWindow(HWND hwndParent)
+{
+  return WinQueryWindow(hwndParent, QW_TOP);
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/user32/new/oslibwin.h
===================================================================
--- trunk/src/user32/new/oslibwin.h	(revision 313)
+++ trunk/src/user32/new/oslibwin.h	(revision 314)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.h,v 1.2 1999-07-15 18:03:02 sandervl Exp $ */
+/* $Id: oslibwin.h,v 1.3 1999-07-16 11:32:08 sandervl Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -30,3 +30,7 @@
 BOOL  OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam);
 
+HWND  OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate);
+
+HWND  OSLibWinQueryTopMostChildWindow(HWND hwndParent);
+
 #endif //__OSLIBWIN_H__
Index: trunk/src/user32/new/win32wnd.cpp
===================================================================
--- trunk/src/user32/new/win32wnd.cpp	(revision 313)
+++ trunk/src/user32/new/win32wnd.cpp	(revision 314)
@@ -1,3 +1,3 @@
-/* $Id: win32wnd.cpp,v 1.3 1999-07-15 18:03:02 sandervl Exp $ */
+/* $Id: win32wnd.cpp,v 1.4 1999-07-16 11:32:09 sandervl Exp $ */
 /*
  * Win32 Window Code for OS/2
@@ -45,5 +45,5 @@
 //******************************************************************************
 Win32Window::Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
-                        : GenericObject(&windows, OBJTYPE_WINDOW)
+                        : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
 {
   Init();
@@ -68,4 +68,5 @@
   magic            = WIN32PM_MAGIC;
   OS2Hwnd          = 0;
+  OS2HwndMenu      = 0;
   Win32Hwnd        = 0;
 
@@ -76,4 +77,7 @@
         DebugInt3();
   }
+  Win32Hwnd       &= 0xFFFF;
+  Win32Hwnd       |= 0x68000000;
+
   posx = posy      = 0;
   width = height   = 0;
@@ -83,5 +87,4 @@
   win32wndproc     = 0;
   hInstance        = 0;
-  parent           = 0;
   windowId         = 0xFFFFFFFF;        //default = -1
   userData         = 0;
@@ -110,5 +113,4 @@
 {
  char  buffer[256];
- DWORD tmp;
  INT   sw = SW_SHOW;
  POINT maxSize, maxPos, minTrack, maxTrack;
@@ -220,14 +222,8 @@
   if ((cs->style & WS_CHILD) && cs->hwndParent)
   {
-        if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR)
-        {
-                dprintf(("HMHandleTranslateToOS2 couldn't find parent window %x!!!", cs->hwndParent));
-                return FALSE;
-        }
-        parent = (Win32Window *)tmp;
+	SetParent(cs->hwndParent);
   }
   else
   {
-        parent = NULL;  //desktop
         if (!cs->hwndParent) {
                 owner = NULL;
@@ -235,10 +231,10 @@
         else
         {
-                if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR)
+		owner = GetWindowFromHandle(cs->hwndParent);
+                if(owner == NULL)
                 {
                         dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent));
                         return FALSE;
                 }
-                owner = (Win32Window *)tmp;
         }
   }
@@ -251,4 +247,27 @@
   hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
                   ? HWND_BOTTOM : HWND_TOP;
+
+#if 0
+//TODO
+    /* Call the WH_CBT hook */
+
+    if (HOOK_IsHooked( WH_CBT ))
+    {
+	CBT_CREATEWNDA cbtc;
+        LRESULT ret;
+
+	cbtc.lpcs = cs;
+	cbtc.hwndInsertAfter = hwndLinkAfter;
+        ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
+                      : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
+        if (ret)
+	{
+	    TRACE_(win)("CBT-hook returned 0\n");
+	    wndPtr->pDriver->pFinalize(wndPtr);
+            retvalue =  0;
+            goto end;
+	}
+    }
+#endif
 
   /* Increment class window counter */
@@ -296,17 +315,9 @@
   }
 
-  /* Set the window menu */
-  if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
-  {
-        if (cs->hMenu) SetMenu(getWindowHandle(), cs->hMenu);
-        else
-        {
-                if (windowClass->getMenuNameA()) {
-                        cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
-                        if (cs->hMenu) SetMenu( getWindowHandle(), cs->hMenu );
-                }
-        }
-  }
-  else  windowId = (UINT)cs->hMenu;
+  rectWindow.left   = cs->x;
+  rectWindow.top    = cs->y;
+  rectWindow.right  = cs->x + cs->cx;
+  rectWindow.bottom = cs->y + cs->cy;
+  rectClient        = rectWindow;
 
   DWORD dwOSWinStyle, dwOSFrameStyle;
@@ -314,5 +325,5 @@
   OSLibWinConvertStyle(cs->style, &dwOSWinStyle, &dwOSFrameStyle);
 
-  OS2Hwnd = OSLibWinCreateWindow((parent) ? parent->getOS2WindowHandle() : 0,
+  OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : 0,
                                  dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName,
                                  cs->x, cs->y, cs->cx, cs->cy,
@@ -333,6 +344,199 @@
   }
 
-  return TRUE;
-}
+  /* Set the window menu */
+  if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
+  {
+        if (cs->hMenu) SetMenu(cs->hMenu);
+        else
+        {
+                if (windowClass->getMenuNameA()) {
+                        cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
+                        if (cs->hMenu) SetMenu(cs->hMenu );
+                }
+        }
+  }
+  else  windowId = (UINT)cs->hMenu;
+
+  /* Send the WM_CREATE message 
+   * Perhaps we shouldn't allow width/height changes as well. 
+   * See p327 in "Internals". 
+   */
+  maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
+
+  if(sendMessage(WM_NCCREATE, 0, (LPARAM)cs) )
+  {
+        SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
+        OffsetRect(&rectWindow, maxPos.x - rectWindow.left,
+                                          maxPos.y - rectWindow.top);
+	dprintf(("Sending WM_CREATE"));
+        if( (sendMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 )
+        {
+            /* Send the size messages */
+	    dprintf(("Sent WM_CREATE"));
+
+            if (!(flags & WIN_NEED_SIZE))
+            {
+                /* send it anyway */
+	        if (((rectClient.right-rectClient.left) <0)
+		    ||((rectClient.bottom-rectClient.top)<0))
+		  dprintf(("sending bogus WM_SIZE message 0x%08lx\n",
+			MAKELONG(rectClient.right-rectClient.left,
+				 rectClient.bottom-rectClient.top)));
+                SendMessageA(WM_SIZE, SIZE_RESTORED,
+                                MAKELONG(rectClient.right-rectClient.left,
+                                         rectClient.bottom-rectClient.top));
+                SendMessageA(WM_MOVE, 0,
+                                MAKELONG( rectClient.left,
+                                          rectClient.top ) );
+            }
+
+#if 0
+            /* Show the window, maximizing or minimizing if needed */
+
+            if (dwStyle & (WS_MINIMIZE | WS_MAXIMIZE))
+            {
+		RECT16 newPos;
+		UINT16 swFlag = (dwStyle & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
+                dwStyle &= ~(WS_MAXIMIZE | WS_MINIMIZE);
+		WINPOS_MinMaximize(swFlag, &newPos );
+                swFlag = ((dwStyle & WS_CHILD) || GetActiveWindow())
+                    ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
+                    : SWP_NOZORDER | SWP_FRAMECHANGED;
+                SetWindowPos(0, newPos.left, newPos.top,
+                             newPos.right, newPos.bottom, swFlag );
+            }
+#endif
+
+	    if( dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
+	    {
+		/* Notify the parent window only */
+
+		NotifyParent(WM_CREATE, 0, 0);
+                if( !IsWindow(Win32Hwnd) )
+                {
+                    return FALSE;
+	        }
+	    }
+
+            if (cs->style & WS_VISIBLE) ShowWindow( sw );
+
+#if 0
+            /* Call WH_SHELL hook */
+
+            if (!(dwStyle & WS_CHILD) && !owner)
+                HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
+#endif
+	    return TRUE;
+        }
+  }
+  return FALSE;
+}
+#if 0
+/***********************************************************************
+ *           WINPOS_MinMaximize
+ *
+ * Fill in lpRect and return additional flags to be used with SetWindowPos().
+ * This function assumes that 'cmd' is different from the current window
+ * state.
+ */
+UINT Win32Window::MinMaximize(UINT16 cmd, LPRECT16 lpRect )
+{
+    UINT swpFlags = 0;
+    POINT pt, size;
+    LPINTERNALPOS lpPos;
+
+    size.x = rectWindow.left; size.y = rectWindow.top;
+    lpPos = WINPOS_InitInternalPos( wndPtr, size, &rectWindow );
+
+    if (lpPos && !HOOK_CallHooks16(WH_CBT, HCBT_MINMAX, hwndSelf, cmd))
+    {
+	if( dwStyle & WS_MINIMIZE )
+	{
+	    if( !SendMessageA(WM_QUERYOPEN, 0, 0L ) )
+		return (SWP_NOSIZE | SWP_NOMOVE);
+	    swpFlags |= SWP_NOCOPYBITS;
+	}
+	switch( cmd )
+	{
+	    case SW_MINIMIZE:
+		 if( dwStyle & WS_MAXIMIZE)
+		 {
+		     flags |= WIN_RESTORE_MAX;
+		     dwStyle &= ~WS_MAXIMIZE;
+                 }
+                 else
+		     flags &= ~WIN_RESTORE_MAX;
+		 dwStyle |= WS_MINIMIZE;
+
+#if 0
+		 if( flags & WIN_NATIVE )
+		     if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
+			 swpFlags |= MINMAX_NOSWP;
+#endif
+
+		 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
+
+		 SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
+			 GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
+		 swpFlags |= SWP_NOCOPYBITS;
+		 break;
+
+	    case SW_MAXIMIZE:
+                CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
+                WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
+                CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
+
+		 if( dwStyle & WS_MINIMIZE )
+		 {
+		     if( flags & WIN_NATIVE )
+			 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
+			     swpFlags |= MINMAX_NOSWP;
+
+		     WINPOS_ShowIconTitle( wndPtr, FALSE );
+		     dwStyle &= ~WS_MINIMIZE;
+		 }
+                 dwStyle |= WS_MAXIMIZE;
+
+		 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
+				    size.x, size.y );
+		 break;
+
+	    case SW_RESTORE:
+		 if( dwStyle & WS_MINIMIZE )
+		 {
+		     if( flags & WIN_NATIVE )
+			 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
+			     swpFlags |= MINMAX_NOSWP;
+
+		     dwStyle &= ~WS_MINIMIZE;
+		     WINPOS_ShowIconTitle( wndPtr, FALSE );
+
+		     if( flags & WIN_RESTORE_MAX)
+		     {
+			 /* Restore to maximized position */
+                         CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
+                         WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
+                         CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
+			 dwStyle |= WS_MAXIMIZE;
+			 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
+			 break;
+		     }
+		 } 
+		 else 
+		     if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
+ 		     else dwStyle &= ~WS_MAXIMIZE;
+
+		 /* Restore to normal position */
+
+		*lpRect = lpPos->rectNormal; 
+		 lpRect->right -= lpRect->left; 
+		 lpRect->bottom -= lpRect->top;
+
+		 break;
+	}
+    } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
+    return swpFlags;
+}
+#endif
 /*******************************************************************
  *           GetMinMaxInfo
@@ -379,5 +583,5 @@
 
 #if 0
-    lpPos = (LPINTERNALPOS)GetPropA( wndPtr->hwndSelf, atomInternalPos );
+    lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
     if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
         CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
@@ -407,4 +611,34 @@
     if (minTrack) *minTrack = MinMax.ptMinTrackSize;
     if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
+}
+/***********************************************************************
+ *           WINPOS_SendNCCalcSize
+ *
+ * Send a WM_NCCALCSIZE message to a window.
+ * All parameters are read-only except newClientRect.
+ * oldWindowRect, oldClientRect and winpos must be non-NULL only
+ * when calcValidRect is TRUE.
+ */
+LONG Win32Window::SendNCCalcSize(BOOL calcValidRect,
+                            RECT *newWindowRect, RECT *oldWindowRect,
+                            RECT *oldClientRect, WINDOWPOS *winpos,
+                            RECT *newClientRect )
+{
+   NCCALCSIZE_PARAMS params;
+   WINDOWPOS winposCopy;
+   LONG result;
+
+   params.rgrc[0] = *newWindowRect;
+   if (calcValidRect)
+   {
+        winposCopy = *winpos;
+	params.rgrc[1] = *oldWindowRect;
+	params.rgrc[2] = *oldClientRect;
+	params.lppos = &winposCopy;
+   }
+   result = SendMessageA(WM_NCCALCSIZE, calcValidRect,
+                          (LPARAM)&params );
+   *newClientRect = params.rgrc[0];
+   return result;
 }
 //******************************************************************************
@@ -613,5 +847,5 @@
 //******************************************************************************
 //******************************************************************************
-LRESULT Win32Window::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
+BOOL Win32Window::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
 {
  POSTMSG_PACKET *postmsg;
@@ -620,4 +854,5 @@
   if(postmsg == NULL) {
 	dprintf(("Win32Window::PostMessageA: malloc returned NULL!!"));
+	return 0;
   }
   postmsg->Msg    = msg;
@@ -628,5 +863,5 @@
 //******************************************************************************
 //******************************************************************************
-LRESULT Win32Window::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)
+BOOL Win32Window::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)
 {
  POSTMSG_PACKET *postmsg;
@@ -635,4 +870,5 @@
   if(postmsg == NULL) {
 	dprintf(("Win32Window::PostMessageW: malloc returned NULL!!"));
+	return 0;
   }
   postmsg->Msg    = msg;
@@ -642,4 +878,5 @@
 }
 //******************************************************************************
+//TODO: do we need to inform the parent of the parent (etc) of the child window?
 //******************************************************************************
 void Win32Window::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
@@ -665,4 +902,137 @@
         window = parentwindow;
    }
+}
+//******************************************************************************
+//******************************************************************************
+BOOL Win32Window::SetMenu(ULONG hMenu)
+{
+ PVOID menutemplate;
+
+   if(HMHandleTranslateToOS2(hMenu, (PULONG)&menutemplate) == NO_ERROR) 
+   {
+	OS2HwndMenu = OSLibWinCreateMenu(OS2Hwnd, menutemplate);
+	if(OS2HwndMenu == 0) {
+		dprintf(("Win32Window::SetMenu OS2HwndMenu == 0"));
+		return FALSE;
+	}
+   }
+   dprintf(("Win32Window::SetMenu unknown hMenu (%x)", hMenu));
+   return FALSE;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL Win32Window::ShowWindow(ULONG nCmdShow)
+{
+  return O32_ShowWindow(OS2Hwnd, nCmdShow);
+}
+//******************************************************************************
+//******************************************************************************
+BOOL Win32Window::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
+{
+ Win32Window *window;
+
+  switch(hwndInsertAfter) {
+  	case HWND_BOTTOM:
+  	case HWND_TOP:
+	case HWND_TOPMOST:
+	case HWND_NOTOPMOST:
+		break;
+	default:
+		window = GetWindowFromHandle(hwndInsertAfter);
+		if(window) {
+			hwndInsertAfter = window->getOS2WindowHandle();
+		}
+		else {
+			dprintf(("Win32Window::SetWindowPos, unknown hwndInsertAfter %x", hwndInsertAfter));
+			hwndInsertAfter = 0;
+		}
+		break;
+		
+  }
+  return O32_SetWindowPos(OS2Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags);
+}
+//******************************************************************************
+BOOL Win32Window::DestroyWindow()
+{
+  return TRUE;
+}
+//******************************************************************************
+//TODO:
+//******************************************************************************
+HWND Win32Window::SetActiveWindow()
+{
+  return O32_SetActiveWindow(OS2Hwnd);
+}
+//******************************************************************************
+//******************************************************************************
+HWND Win32Window::GetParent()
+{
+  if(getParent()) {
+	return getParent()->getWindowHandle();
+  }
+  else	return 0;
+}
+//******************************************************************************
+//******************************************************************************
+HWND Win32Window::SetParent(HWND hwndNewParent)
+{
+ HWND oldhwnd;
+ Win32Window *newparent;
+
+   if(getParent()) {
+    	oldhwnd = getParent()->getWindowHandle();
+   }
+   else oldhwnd = 0;
+
+   if(hwndNewParent == 0) {//desktop window = parent
+ 	setParent(NULL);
+        OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
+        return oldhwnd;
+   }
+   newparent = GetWindowFromHandle(hwndNewParent);
+   if(newparent)
+   {
+        setParent(newparent);
+        OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
+        return oldhwnd;
+   }
+   SetLastError(ERROR_INVALID_PARAMETER);
+   return 0;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL Win32Window::IsChild(HWND hwndParent)
+{
+  if(getParent()) {
+	return getParent()->getWindowHandle() == hwndParent;
+  }
+  else 	return 0;
+}
+//******************************************************************************
+//******************************************************************************
+HWND Win32Window::GetTopWindow()
+{
+ HWND topchild;
+
+  topchild = OSLibWinQueryTopMostChildWindow(OS2Hwnd);
+  if(topchild)
+  {//TODO
+	return topchild;
+  }
+  else	return 0;
+}
+//******************************************************************************
+//TODO
+//******************************************************************************
+BOOL Win32Window::UpdateWindow()
+{  
+  return TRUE;
+}
+//******************************************************************************
+//TODO
+//******************************************************************************
+BOOL Win32Window::IsIconic()
+{
+  return FALSE;
 }
 //******************************************************************************
@@ -690,26 +1060,6 @@
                 return oldval;
         case GWL_HWNDPARENT:
-        {
-         ULONG tmp;
-
-                if(getParent()) {
-                        oldval = getParent()->getWindowHandle();
-                }
-                else    oldval = 0;
-
-                if(value == 0) {//desktop window = parent
-                        setParent(NULL);
-                        OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
-                        return oldval;
-                }
-                if(HMHandleTranslateToOS2(value, &tmp) == NO_ERROR)
-                {
-                        setParent((Win32Window *)tmp);
-                        OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
-                        return oldval;
-                }
-                SetLastError(ERROR_INVALID_PARAMETER);
-                return 0;
-        }
+		return SetParent((HWND)value);
+
         case GWL_ID:
                 oldval = getWindowId();
@@ -790,3 +1140,17 @@
 //******************************************************************************
 //******************************************************************************
+Win32Window *Win32Window::GetWindowFromHandle(HWND hwnd)
+{
+ Win32Window *window;
+
+   if(HIWORD(hwnd) != 0x6800)
+	return NULL;
+
+   if(HMHandleTranslateToOS2(LOWORD(hwnd), (PULONG)&window) == NO_ERROR) {
+	return window;
+   }
+   else return NULL;
+}
+//******************************************************************************
+//******************************************************************************
 GenericObject *Win32Window::windows  = NULL;
Index: trunk/src/user32/new/win32wnd.h
===================================================================
--- trunk/src/user32/new/win32wnd.h	(revision 313)
+++ trunk/src/user32/new/win32wnd.h	(revision 314)
@@ -1,3 +1,3 @@
-/* $Id: win32wnd.h,v 1.3 1999-07-15 18:03:03 sandervl Exp $ */
+/* $Id: win32wnd.h,v 1.4 1999-07-16 11:32:09 sandervl Exp $ */
 /*
  * Win32 Window Code for OS/2
@@ -17,9 +17,7 @@
 #include <win32class.h>
 #include <gen_object.h>
+#include <win32wndchild.h>
 
 class Win32Window;
-
-#define WIN2OS2HWND(a)	(Win32Window*)(a^a)
-#define OS22WINHWND(a)	(a^a)
 
 #define OFFSET_WIN32WNDPTR	0
@@ -44,5 +42,5 @@
 #define WM_WIN32_POSTMESSAGEW	0x4001
 
-class Win32Window : public GenericObject
+class Win32Window : private GenericObject, private ChildWindow
 {
 public:
@@ -77,6 +75,6 @@
 	 HWND   getWindowHandle() 		{ return Win32Hwnd; };
 	 HWND   getOS2WindowHandle() 		{ return OS2Hwnd; };
-   Win32Window *getParent()			{ return parent; };
-	 void   setParent(Win32Window *pwindow) { parent = pwindow; };
+   Win32Window *getParent()			{ return (Win32Window *)ChildWindow::GetParent(); };
+	 void   setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
        WNDPROC  getWindowProc()                 { return win32wndproc; };
          void   setWindowProc(WNDPROC newproc)  { win32wndproc = newproc; };
@@ -87,8 +85,20 @@
 	 void   setFlags(DWORD newflags)	{ flags = newflags; };
 
+	 BOOL   SetMenu(ULONG hMenu);
+	 BOOL   ShowWindow(ULONG nCmdShow);
+	 BOOL   SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
+	 BOOL   DestroyWindow();
+	 HWND   SetActiveWindow();
+	 HWND   GetParent();
+	 HWND   SetParent(HWND hwndNewParent);
+	 BOOL   IsChild(HWND hwndParent);
+	 HWND   GetTopWindow();
+	 BOOL   UpdateWindow();
+	 BOOL   IsIconic();
+
        LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
        LRESULT  SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
-       LRESULT  PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
-       LRESULT  PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
+       BOOL     PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
+       BOOL     PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
        LRESULT  DefWindowProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
        LRESULT  DefWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -98,9 +108,11 @@
 Win32WndClass  *getClass()  { return windowClass; };
 
+static Win32Window *GetWindowFromHandle(HWND hwnd);
+
 protected:
 	void    Init();
 
-
 	HWND	OS2Hwnd;
+	HWND    OS2HwndMenu;
 	HWND	Win32Hwnd;
 	BOOL    isUnicode;
@@ -113,5 +125,6 @@
       WNDPROC   win32wndproc;		//GWL_WNDPROC
 	ULONG   hInstance;		//GWL_HINSTANCE
-   Win32Window *parent;			//GWL_HWNDPARENT
+//Moved in ChildWindow class
+/////   Win32Window *parent;			//GWL_HWNDPARENT
 	ULONG	windowId;		//GWL_ID
 	ULONG	userData;		//GWL_USERDATA
@@ -131,4 +144,7 @@
 	ULONG	nrUserWindowLong;
 
+	RECT    rectWindow;
+	RECT    rectClient;
+
 Win32WndClass  *windowClass;
 
@@ -136,7 +152,21 @@
 
 private:
+#ifndef OS2_INCLUDED
 	BOOL  CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
 
 	void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
+
+	LONG  SendNCCalcSize(BOOL calcValidRect,
+                             RECT *newWindowRect, RECT *oldWindowRect,
+                             RECT *oldClientRect, WINDOWPOS *winpos,
+                             RECT *newClientRect );
+
+     LRESULT  sendMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
+     {
+	if(isUnicode)
+		return SendMessageW(msg, wParam, lParam);
+	else	return SendMessageA(msg, wParam, lParam);
+     }
+#endif
 };
 
Index: trunk/src/user32/new/win32wndchild.cpp
===================================================================
--- trunk/src/user32/new/win32wndchild.cpp	(revision 314)
+++ trunk/src/user32/new/win32wndchild.cpp	(revision 314)
@@ -0,0 +1,92 @@
+/* $Id: win32wndchild.cpp,v 1.1 1999-07-16 11:32:09 sandervl Exp $ */
+/*
+ * Win32 Child/Parent window class for OS/2
+ *
+ *
+ * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
+ *
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+#include <os2win.h>
+#include <win32wndchild.h>
+#include <misc.h>
+
+//******************************************************************************
+//******************************************************************************
+ChildWindow::ChildWindow()
+{
+  parent           = 0;
+  nextchild        = 0;
+  children         = 0;
+}
+//******************************************************************************
+//******************************************************************************
+ChildWindow::~ChildWindow()
+{
+  if(parent) {
+	parent->RemoveChild(this);
+  }
+  if(children != 0) {
+	dprintf(("ChildWindow::~ChildWindow children not yet destroyed!!"));
+	DestroyChildren();
+  }
+}
+//******************************************************************************
+//LIFO insertion
+//******************************************************************************
+BOOL ChildWindow::AddChild(ChildWindow *child)
+{
+   mutex.enter();
+
+   child->SetNextChild(children);
+   children = child;
+
+   mutex.leave();
+   return TRUE;
+}
+//******************************************************************************
+//Remove child from linked list. Doesn't delete it!
+//******************************************************************************
+BOOL ChildWindow::RemoveChild(ChildWindow *child)
+{
+ ChildWindow *curchild = children;
+
+   mutex.enter();
+
+   if(curchild == child) {
+	children = child->GetNextChild();	
+   }
+   else {
+	if(curchild == NULL) {
+		dprintf(("ChildWindow::RemoveChild, children == NULL"));
+		DebugInt3();
+		mutex.leave();
+		return FALSE;
+	}
+	while(curchild->GetNextChild() != child) {
+		curchild = curchild->GetNextChild();
+		if(curchild == NULL) {
+			dprintf(("ChildWindow::RemoveChild, curchild == NULL"));
+			DebugInt3();
+			mutex.leave();
+			return FALSE;
+		}	
+	}
+	curchild->SetNextChild(child->GetNextChild());
+   }
+   mutex.leave();
+   return TRUE;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL ChildWindow::DestroyChildren()
+{
+   while(children) {
+	delete children;	//child dtor removes itself from the linked list
+   }
+   return TRUE;
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/user32/new/win32wndchild.h
===================================================================
--- trunk/src/user32/new/win32wndchild.h	(revision 314)
+++ trunk/src/user32/new/win32wndchild.h	(revision 314)
@@ -0,0 +1,54 @@
+/* $Id: win32wndchild.h,v 1.1 1999-07-16 11:32:09 sandervl Exp $ */
+/*
+ * Win32 Child/Parent window class for OS/2
+ *
+ *
+ * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
+ *
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+#ifndef __WIN32WNDCHILD_H__
+#define __WIN32WNDCHILD_H__
+
+#include <vmutex.h>
+
+#ifdef __cplusplus
+
+class ChildWindow
+{
+public:
+ 	 ChildWindow();
+virtual ~ChildWindow();
+
+protected:
+
+ ChildWindow *GetParent()			{ return parent; };
+ ChildWindow *SetParent(ChildWindow *newParent)
+ {
+  ChildWindow *oldparent = parent;
+
+	parent = newParent;
+	return oldparent;
+ }                   
+
+	BOOL   AddChild(ChildWindow *child);
+	BOOL   RemoveChild(ChildWindow *child);
+ChildWindow   *GetNextChild()   		{ return nextchild; };
+        void   SetNextChild(ChildWindow *child)	{ nextchild = child; };
+
+	BOOL   DestroyChildren();
+
+private:
+        VMutex mutex;
+
+   ChildWindow *parent;		//GWL_HWNDPARENT
+   ChildWindow *children;	//linked list of children of this window
+   ChildWindow *nextchild;	//pointer to next child of our parent window
+};
+
+
+#endif //__cplusplus
+
+#endif //__WIN32WNDCHILD_H__
Index: trunk/src/user32/new/window.cpp
===================================================================
--- trunk/src/user32/new/window.cpp	(revision 313)
+++ trunk/src/user32/new/window.cpp	(revision 314)
@@ -1,3 +1,3 @@
-/* $Id: window.cpp,v 1.2 1999-07-14 21:05:59 cbratschi Exp $ */
+/* $Id: window.cpp,v 1.3 1999-07-16 11:32:09 sandervl Exp $ */
 /*
  * Win32 window apis for OS/2
@@ -178,55 +178,79 @@
 //******************************************************************************
 //******************************************************************************
-BOOL WIN32API DestroyWindow(HWND arg1)
-{
-#ifdef DEBUG
-    WriteLog("USER32:  DestroyWindow\n");
-#endif
-    return O32_DestroyWindow(arg1);
-}
-//******************************************************************************
-//******************************************************************************
-HWND WIN32API SetActiveWindow( HWND arg1)
-{
-#ifdef DEBUG
-    WriteLog("USER32:  SetActiveWindow\n");
-#endif
-    return O32_SetActiveWindow(arg1);
-}
-//******************************************************************************
-//******************************************************************************
-HWND WIN32API GetParent( HWND arg1)
-{
-#ifdef DEBUG
-////    WriteLog("USER32:  GetParent\n");
-#endif
-    return O32_GetParent(arg1);
-}
-//******************************************************************************
-//******************************************************************************
-HWND WIN32API SetParent( HWND arg1, HWND  arg2)
-{
-#ifdef DEBUG
-    WriteLog("USER32:  SetParent\n");
-#endif
-    return O32_SetParent(arg1, arg2);
-}
-//******************************************************************************
-//******************************************************************************
-BOOL WIN32API IsChild( HWND arg1, HWND  arg2)
-{
-#ifdef DEBUG
-    WriteLog("USER32:  IsChild\n");
-#endif
-    return O32_IsChild(arg1, arg2);
-}
-//******************************************************************************
-//******************************************************************************
-HWND WIN32API GetTopWindow( HWND arg1)
-{
-#ifdef DEBUG
-////    WriteLog("USER32:  GetTopWindow\n");
-#endif
-    return O32_GetTopWindow(arg1);
+BOOL WIN32API DestroyWindow(HWND hwnd)
+{
+  Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
+	dprintf(("SendMessageA, window %x not found", hwnd));
+	return 0;
+    }
+    return window->DestroyWindow();
+}
+//******************************************************************************
+//******************************************************************************
+HWND WIN32API SetActiveWindow( HWND hwnd)
+{
+  Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
+	dprintf(("SendMessageA, window %x not found", hwnd));
+	return 0;
+    }
+    return window->SetActiveWindow();
+}
+//******************************************************************************
+//******************************************************************************
+HWND WIN32API GetParent( HWND hwnd)
+{
+  Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
+	dprintf(("SendMessageA, window %x not found", hwnd));
+	return 0;
+    }
+    return window->GetParent();
+}
+//******************************************************************************
+//******************************************************************************
+HWND WIN32API SetParent( HWND hwndChild, HWND hwndNewParent)
+{
+  Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwndChild);
+    if(!window) {
+	dprintf(("SendMessageA, window %x not found", hwndChild));
+	return 0;
+    }
+    return window->SetParent(hwndNewParent);
+}
+//******************************************************************************
+//******************************************************************************
+BOOL WIN32API IsChild( HWND hwndParent, HWND hwnd)
+{
+  Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
+	dprintf(("SendMessageA, window %x not found", hwnd));
+	return 0;
+    }
+    return window->IsChild(hwndParent);
+}
+//******************************************************************************
+//******************************************************************************
+HWND WIN32API GetTopWindow( HWND hwnd)
+{
+  Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
+	dprintf(("SendMessageA, window %x not found", hwnd));
+	return 0;
+    }
+    return window->GetTopWindow();
 }
 //******************************************************************************
@@ -234,16 +258,25 @@
 BOOL WIN32API UpdateWindow(HWND hwnd)
 {
-  dprintf(("USER32:  UpdateWindow\n"));
-
-  return O32_UpdateWindow(hwnd);
-}
-//******************************************************************************
-//******************************************************************************
-BOOL WIN32API IsIconic( HWND arg1)
-{
-#ifdef DEBUG
-    WriteLog("USER32:  IsIconic\n");
-#endif
-    return O32_IsIconic(arg1);
+  Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
+	dprintf(("SendMessageA, window %x not found", hwnd));
+	return 0;
+    }
+    return window->UpdateWindow();
+}
+//******************************************************************************
+//******************************************************************************
+BOOL WIN32API IsIconic( HWND hwnd)
+{
+  Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
+	dprintf(("SendMessageA, window %x not found", hwnd));
+	return 0;
+    }
+    return window->IsIconic();
 }
 //******************************************************************************
Index: trunk/src/user32/new/windowclass.cpp
===================================================================
--- trunk/src/user32/new/windowclass.cpp	(revision 313)
+++ trunk/src/user32/new/windowclass.cpp	(revision 314)
@@ -1,3 +1,3 @@
-/* $Id: windowclass.cpp,v 1.4 1999-07-15 18:54:55 sandervl Exp $ */
+/* $Id: windowclass.cpp,v 1.5 1999-07-16 11:32:09 sandervl Exp $ */
 /*
  * Win32 Window Class Code for OS/2
@@ -19,5 +19,4 @@
 #include <win32class.h>
 #include <win32wnd.h>
-#include <handlemanager.h>
 
 //******************************************************************************
@@ -261,5 +260,6 @@
 
     dprintf(("USER32: GetClassNameA\n"));
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
+    wnd = Win32Window::GetWindowFromHandle(hwnd);
+    if(!wnd) {
         dprintf(("GetClassNameA wnd == NULL"));
         return(0);
@@ -274,5 +274,6 @@
 
     dprintf(("USER32: GetClassNameW\n"));
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
+    wnd = Win32Window::GetWindowFromHandle(hwnd);
+    if(!wnd) {
         dprintf(("GetClassNameA wnd == NULL"));
         return(0);
@@ -287,5 +288,6 @@
 
     dprintf(("USER32: SetClassLongA\n"));
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
+    wnd = Win32Window::GetWindowFromHandle(hwnd);
+    if(!wnd) {
         dprintf(("SetClassLongA wnd == NULL"));
         return(0);
@@ -300,5 +302,6 @@
 
     dprintf(("USER32: SetClassLongW\n"));
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
+    wnd = Win32Window::GetWindowFromHandle(hwnd);
+    if(!wnd) {
         dprintf(("SetClassLongW wnd == NULL"));
         return(0);
@@ -313,5 +316,6 @@
 
     dprintf(("USER32: SetClassWordA\n"));
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
+    wnd = Win32Window::GetWindowFromHandle(hwnd);
+    if(!wnd) {
         dprintf(("SetClassWordA wnd == NULL"));
         return(0);
@@ -326,5 +330,6 @@
 
     dprintf(("USER32: GetClassWordA\n"));
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
+    wnd = Win32Window::GetWindowFromHandle(hwnd);
+    if(!wnd) {
         dprintf(("GetClassWordA wnd == NULL"));
         return(0);
@@ -339,5 +344,6 @@
 
     dprintf(("USER32: GetClassLongA\n"));
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
+    wnd = Win32Window::GetWindowFromHandle(hwnd);
+    if(!wnd) {
         dprintf(("GetClassLongA wnd == NULL"));
         return(0);
@@ -352,5 +358,6 @@
 
     dprintf(("USER32: GetClassLongW\n"));
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&wnd) != NO_ERROR) {
+    wnd = Win32Window::GetWindowFromHandle(hwnd);
+    if(!wnd) {
         dprintf(("GetClassLongW wnd == NULL"));
         return(0);
Index: trunk/src/user32/new/windowmsg.cpp
===================================================================
--- trunk/src/user32/new/windowmsg.cpp	(revision 313)
+++ trunk/src/user32/new/windowmsg.cpp	(revision 314)
@@ -1,3 +1,3 @@
-/* $Id: windowmsg.cpp,v 1.4 1999-07-15 18:41:46 sandervl Exp $ */
+/* $Id: windowmsg.cpp,v 1.5 1999-07-16 11:32:10 sandervl Exp $ */
 /*
  * Win32 window message APIs for OS/2
@@ -16,5 +16,4 @@
 #include <misc.h>
 #include <win32wnd.h>
-#include <handlemanager.h>
 #include <win.h>
 #include <hooks.h>
@@ -47,5 +46,6 @@
     if (!msg->hwnd) return 0;
 
-    if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
+    window = Win32Window::GetWindowFromHandle(msg->hwnd);
+    if(!window) {
 	dprintf(("DispatchMessageA, window %x not found", msg->hwnd));
 	return 0;
@@ -58,5 +58,6 @@
 
 #if 0
-    if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
+    window = Win32Window::GetWindowFromHandle(msg->hwnd);
+    if(!window) {
 	dprintf(("DispatchMessageA, window %x not found", msg->hwnd));
 	return 0;
@@ -93,5 +94,6 @@
     if (!msg->hwnd) return 0;
 
-    if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
+    window = Win32Window::GetWindowFromHandle(msg->hwnd);
+    if(!window) {
 	dprintf(("DispatchMessageW, window %x not found", msg->hwnd));
 	return 0;
@@ -104,5 +106,6 @@
 
 #if 0
-    if(HMHandleTranslateToOS2(msg->hwnd, (PULONG)&window) != NO_ERROR) {
+    window = Win32Window::GetWindowFromHandle(msg->hwnd);
+    if(!window) {
 	dprintf(("DispatchMessageW, window %x not found", msg->hwnd));
 	return 0;
@@ -136,5 +139,6 @@
   Win32Window *window;
 
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
 	dprintf(("SendMessageA, window %x not found", hwnd));
 	return 0;
@@ -149,5 +153,6 @@
   Win32Window *window;
 
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
 	dprintf(("SendMessageW, window %x not found", hwnd));
 	return 0;
@@ -165,5 +170,6 @@
 	return PostThreadMessageA(GetCurrentThreadId(), msg, wParam, lParam);
 
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
 	dprintf(("PostMessageA, window %x not found", hwnd));
 	return 0;
@@ -181,5 +187,6 @@
 	return PostThreadMessageW(GetCurrentThreadId(), msg, wParam, lParam);
 
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) != NO_ERROR) {
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(!window) {
 	dprintf(("PostMessageW, window %x not found", hwnd));
 	return 0;
Index: trunk/src/user32/new/windowword.cpp
===================================================================
--- trunk/src/user32/new/windowword.cpp	(revision 313)
+++ trunk/src/user32/new/windowword.cpp	(revision 314)
@@ -1,3 +1,3 @@
-/* $Id: windowword.cpp,v 1.1 1999-07-14 08:35:37 sandervl Exp $ */
+/* $Id: windowword.cpp,v 1.2 1999-07-16 11:32:10 sandervl Exp $ */
 
 /*
@@ -14,5 +14,4 @@
 
 #include <win32wnd.h>
-#include <handlemanager.h>
 
 //******************************************************************************
@@ -22,5 +21,6 @@
  Win32Window *window;
 
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(window)
     {
 	return window->SetWindowLongA(nIndex, arg3);
@@ -38,5 +38,6 @@
  Win32Window *window;
 
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(window)
     {
 	return window->SetWindowLongA(nIndex, arg3);
@@ -54,5 +55,6 @@
  Win32Window *window;
 
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(window)
     {
 	return window->GetWindowWord(nIndex);
@@ -70,5 +72,6 @@
  Win32Window *window;
 
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(window)
     {
 	return window->SetWindowWord(nIndex, arg3);
@@ -86,5 +89,6 @@
  Win32Window *window;
 
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(window)
     {
 	return window->GetWindowLongA(nIndex);
@@ -102,5 +106,6 @@
  Win32Window *window;
 
-    if(HMHandleTranslateToOS2(hwnd, (PULONG)&window) == NO_ERROR)
+    window = Win32Window::GetWindowFromHandle(hwnd);
+    if(window)
     {
 	return window->GetWindowLongA(nIndex);
