Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 3662)
+++ trunk/src/user32/win32wbase.cpp	(revision 3663)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.198 2000-06-07 14:51:30 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.199 2000-06-07 21:45:50 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -1158,4 +1158,10 @@
 //******************************************************************************
 //******************************************************************************
+BOOL Win32BaseWindow::isDesktopWindow()
+{
+  return FALSE;
+}
+//******************************************************************************
+//******************************************************************************
 BOOL Win32BaseWindow::IsWindowIconic()
 {
@@ -2395,5 +2401,5 @@
 Win32BaseWindow *Win32BaseWindow::getParent()
 {
-  Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::GetParent();
+  Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
   return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
 }
@@ -2402,8 +2408,15 @@
 HWND Win32BaseWindow::GetParent()
 {
+  if((!(getStyle() & (WS_POPUP|WS_CHILD)))) {
+  	return 0;
+  }
+
+  Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
+
   if(getStyle() & WS_CHILD) {
-	if(getParent()) {
-		return getParent()->getWindowHandle();
+	if(wndparent) {
+		return wndparent->getWindowHandle();
 	}
+	dprintf(("WARNING: GetParent: WS_CHILD but no parent!!"));
 	DebugInt3();
 	return 0;
@@ -2417,10 +2430,10 @@
  HWND oldhwnd;
  Win32BaseWindow *newparent;
- Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::GetParent();
+ Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
  BOOL fShow = FALSE;
 
    if(oldparent) {
         oldhwnd = oldparent->getWindowHandle();
-        oldparent->RemoveChild(this);
+        oldparent->removeChild(this);
    }
    else oldhwnd = 0;
@@ -2434,14 +2447,28 @@
 
    newparent = GetWindowFromHandle(hwndNewParent);
-   if(newparent)
+   if(newparent && !newparent->isDesktopWindow())
    {
         setParent(newparent);
-        getParent()->AddChild(this);
+        getParent()->addChild(this);
         OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
+        if(!(getStyle() & WS_CHILD))
+        {
+		//TODO: Send WM_STYLECHANGED msg?
+        	setStyle(getStyle() | WS_CHILD);
+        	if(getWindowId())
+                {
+                        DestroyMenu( (HMENU) getWindowId() );
+                        setWindowId(0);
+                }
+        }
    }
    else {
         setParent(windowDesktop);
-        windowDesktop->AddChild(this);
+        windowDesktop->addChild(this);
         OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
+	
+	//TODO: Send WM_STYLECHANGED msg?
+       	setStyle(getStyle() & ~WS_CHILD);
+        setWindowId(0);
    }
    /* SetParent additionally needs to make hwndChild the topmost window
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 3662)
+++ trunk/src/user32/win32wbase.h	(revision 3663)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.97 2000-06-07 14:51:31 sandervl Exp $ */
+/* $Id: win32wbase.h,v 1.98 2000-06-07 21:45:52 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -156,9 +156,10 @@
 virtual  BOOL   isMDIClient();
 virtual  BOOL   isMDIChild();
+virtual  BOOL   isDesktopWindow();
 
          BOOL   fHasParentDC()                  { return fParentDC; };
 
 Win32BaseWindow *getParent();
-         void   setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
+         void   setParent(Win32BaseWindow *pwindow) { setParentOfChild((ChildWindow *)pwindow); };
        WNDPROC  getWindowProc()                 { return win32wndproc; };
          void   setWindowProc(WNDPROC newproc)  { win32wndproc = newproc; };
Index: trunk/src/user32/win32wdesktop.cpp
===================================================================
--- trunk/src/user32/win32wdesktop.cpp	(revision 3662)
+++ trunk/src/user32/win32wdesktop.cpp	(revision 3663)
@@ -1,3 +1,3 @@
-/* $Id: win32wdesktop.cpp,v 1.13 2000-06-07 14:51:33 sandervl Exp $ */
+/* $Id: win32wdesktop.cpp,v 1.14 2000-06-07 21:45:52 sandervl Exp $ */
 /*
  * Win32 Desktop Window for OS/2
@@ -72,4 +72,10 @@
 }
 //******************************************************************************
+//******************************************************************************
+BOOL Win32Desktop::isDesktopWindow()
+{
+  return TRUE;
+}
+//******************************************************************************
 //Disabling the desktop is not a good idea (mouse no longer responds)
 //******************************************************************************
Index: trunk/src/user32/win32wdesktop.h
===================================================================
--- trunk/src/user32/win32wdesktop.h	(revision 3662)
+++ trunk/src/user32/win32wdesktop.h	(revision 3663)
@@ -1,3 +1,3 @@
-/* $Id: win32wdesktop.h,v 1.6 2000-01-18 20:08:17 sandervl Exp $ */
+/* $Id: win32wdesktop.h,v 1.7 2000-06-07 21:45:52 sandervl Exp $ */
 /*
  * Win32 Desktop Window for OS/2
@@ -25,4 +25,6 @@
  virtual BOOL   EnableWindow(BOOL fEnable);
 
+virtual  BOOL   isDesktopWindow();
+
 protected:
 private:
Index: trunk/src/user32/win32wndchild.cpp
===================================================================
--- trunk/src/user32/win32wndchild.cpp	(revision 3662)
+++ trunk/src/user32/win32wndchild.cpp	(revision 3663)
@@ -1,3 +1,3 @@
-/* $Id: win32wndchild.cpp,v 1.5 2000-02-16 14:28:25 sandervl Exp $ */
+/* $Id: win32wndchild.cpp,v 1.6 2000-06-07 21:45:52 sandervl Exp $ */
 /*
  * Win32 Child/Parent window class for OS/2
@@ -30,5 +30,5 @@
 {
   if(parent) {
-	parent->RemoveChild(this);
+	parent->removeChild(this);
   }
 //SvL: PM sends WM_DESTROY for all the children
@@ -43,5 +43,5 @@
 //FIFO insertion
 //******************************************************************************
-BOOL ChildWindow::AddChild(ChildWindow *child)
+BOOL ChildWindow::addChild(ChildWindow *child)
 {
  ChildWindow *curchild;
@@ -67,5 +67,5 @@
 //Remove child from linked list. Doesn't delete it!
 //******************************************************************************
-BOOL ChildWindow::RemoveChild(ChildWindow *child)
+BOOL ChildWindow::removeChild(ChildWindow *child)
 {
  ChildWindow *curchild = children;
@@ -99,5 +99,5 @@
 //******************************************************************************
 //******************************************************************************
-BOOL ChildWindow::DestroyChildren()
+BOOL ChildWindow::destroyChildren()
 {
    while(children) {
Index: trunk/src/user32/win32wndchild.h
===================================================================
--- trunk/src/user32/win32wndchild.h	(revision 3662)
+++ trunk/src/user32/win32wndchild.h	(revision 3663)
@@ -1,3 +1,3 @@
-/* $Id: win32wndchild.h,v 1.4 2000-01-18 20:08:17 sandervl Exp $ */
+/* $Id: win32wndchild.h,v 1.5 2000-06-07 21:45:52 sandervl Exp $ */
 /*
  * Win32 Child/Parent window class for OS/2
@@ -28,6 +28,6 @@
 protected:
 
- ChildWindow *GetParent()			{ return parent; };
- ChildWindow *SetParent(ChildWindow *newParent)
+ ChildWindow *getParentOfChild()		{ return parent; };
+ ChildWindow *setParentOfChild(ChildWindow *newParent)
  {
   ChildWindow *oldparent = parent;
@@ -37,10 +37,10 @@
  }                   
 
-	BOOL   AddChild(ChildWindow *child);
-	BOOL   RemoveChild(ChildWindow *child);
+	BOOL   addChild(ChildWindow *child);
+	BOOL   removeChild(ChildWindow *child);
 
         void   setNextChild(ChildWindow *child)	{ nextchild = child; };
 
-	BOOL   DestroyChildren();
+	BOOL   destroyChildren();
 
 private:
Index: trunk/src/user32/window.cpp
===================================================================
--- trunk/src/user32/window.cpp	(revision 3662)
+++ trunk/src/user32/window.cpp	(revision 3663)
@@ -1,3 +1,3 @@
-/* $Id: window.cpp,v 1.68 2000-06-07 14:51:33 sandervl Exp $ */
+/* $Id: window.cpp,v 1.69 2000-06-07 21:45:52 sandervl Exp $ */
 /*
  * Win32 window apis for OS/2
@@ -318,4 +318,8 @@
         return 0;
     }
+    if(window->isDesktopWindow()) {
+	dprintf(("WARNING: Trying to destroy desktop window!"));
+	return FALSE;
+    }
     return window->DestroyWindow();
 }
@@ -353,5 +357,5 @@
 HWND WIN32API SetParent( HWND hwndChild, HWND hwndNewParent)
 {
-  Win32BaseWindow *window;
+  Win32BaseWindow *window, *parent;
 
     window = Win32BaseWindow::GetWindowFromHandle(hwndChild);
@@ -360,4 +364,15 @@
         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
         return 0;
+    }
+    if(hwndNewParent == HWND_DESKTOP) {
+	hwndNewParent = GetDesktopWindow();
+    } 
+    else {
+    	parent = Win32BaseWindow::GetWindowFromHandle(hwndNewParent);
+    	if(!window) {
+        	dprintf(("SetParent, parent %x not found", hwndNewParent));
+	        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
+	        return 0;
+	}
     }
     dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
