Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 1948)
+++ trunk/src/user32/win32wbase.cpp	(revision 1949)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.101 1999-12-01 18:43:08 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.102 1999-12-02 19:30:40 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -415,4 +415,5 @@
   else
   {
+        SetParent(0);
         if (!cs->hwndParent || cs->hwndParent == windowDesktop->getWindowHandle()) {
             owner = NULL;
@@ -2447,10 +2448,22 @@
 //******************************************************************************
 //******************************************************************************
+Win32BaseWindow *Win32BaseWindow::getParent()
+{
+  Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::GetParent();
+  return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
+}
+//******************************************************************************
+//******************************************************************************
 HWND Win32BaseWindow::GetParent()
 {
-  if(getParent()) {
-        return getParent()->getWindowHandle();
-  }
-  else  return 0;
+ Win32BaseWindow *wndparent;
+
+    if ((!(getStyle() & (WS_POPUP|WS_CHILD))))
+    {
+        return 0;
+    }
+    wndparent = ((getStyle() & WS_CHILD) ? getParent() : getOwner());
+
+    return (wndparent) ? wndparent->getWindowHandle() : 0;
 }
 //******************************************************************************
@@ -2476,6 +2489,6 @@
    }
    else {
-    setParent(windowDesktop);
-        getParent()->AddChild(this);
+        setParent(windowDesktop);
+        windowDesktop->AddChild(this);
         OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
         return oldhwnd;
@@ -2557,4 +2570,7 @@
         dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
         hwnd = child->getWindowHandle();
+        if(child->getOwner()) {
+                continue; //shouldn't have an owner (Wine)
+        }
         if(lpfn(hwnd, lParam) == FALSE)
         {
@@ -2580,4 +2596,51 @@
     }
     return rc;
+}
+//******************************************************************************
+//Enumerate first-level children only and check thread id
+//******************************************************************************
+BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
+{
+ Win32BaseWindow *child = 0;
+ ULONG  tid, pid;
+ BOOL   rc;
+ HWND   hwnd;
+
+    dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
+
+    for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
+    {
+        OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
+	
+        if(dwThreadId == tid) {
+            dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
+            if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
+                break;
+            }
+        }
+    }
+    return TRUE;
+}
+//******************************************************************************
+//Enumerate first-level children only
+//******************************************************************************
+BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
+{
+ Win32BaseWindow *child = 0;
+ BOOL   rc;
+ HWND   hwnd;
+
+    dprintf(("EnumWindows %x %x", lpfn, lParam));
+
+    for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
+    {
+        hwnd = child->getWindowHandle();
+
+        dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
+        if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
+            break;
+        }
+    }
+    return TRUE;
 }
 //******************************************************************************
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 1948)
+++ trunk/src/user32/win32wbase.h	(revision 1949)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.47 1999-12-01 16:58:29 achimha Exp $ */
+/* $Id: win32wbase.h,v 1.48 1999-12-02 19:30:41 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -122,5 +122,5 @@
 virtual  BOOL   isMDIChild();
 
-Win32BaseWindow *getParent()                    { return (Win32BaseWindow *)ChildWindow::GetParent(); };
+Win32BaseWindow *getParent();
          void   setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
        WNDPROC  getWindowProc()                 { return win32wndproc; };
@@ -229,4 +229,6 @@
 
            BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
+	   BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
+	   BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
 
          HWND   getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
Index: trunk/src/user32/window.cpp
===================================================================
--- trunk/src/user32/window.cpp	(revision 1948)
+++ trunk/src/user32/window.cpp	(revision 1949)
@@ -1,3 +1,3 @@
-/* $Id: window.cpp,v 1.38 1999-11-25 19:22:04 sandervl Exp $ */
+/* $Id: window.cpp,v 1.39 1999-12-02 19:30:41 sandervl Exp $ */
 /*
  * Win32 window apis for OS/2
@@ -1324,35 +1324,5 @@
 BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
 {
- Win32BaseWindow *window;
- BOOL   rc;
- ULONG  henum;
- HWND   hwndNext;
- ULONG  tid;
- ULONG  pid, curpid;
-
-  dprintf(("EnumThreadWindows\n"));
-
-  curpid = GetCurrentProcessId();
-
-  henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
-  while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
-  {
-        OSLibWinQueryWindowProcess(hwndNext, &pid, &tid);
-        if(!(curpid == pid && dwThreadId == tid))
-                continue;
-
-        window = Win32BaseWindow::GetWindowFromOS2Handle(hwndNext);
-        if(window == NULL) {
-                window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndNext);
-                if(!window) {
-                        //OS/2 window or non-frame window, so skip it
-                        continue;
-                }
-        }
-        if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE)
-                break;
-  }
-  OSLibWinEndEnumWindows (henum);
-  return TRUE;
+  return windowDesktop->EnumThreadWindows(dwThreadId, lpfn, lParam); 
 }
 //******************************************************************************
@@ -1382,37 +1352,5 @@
 BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
 {
- Win32BaseWindow *window;
- BOOL   rc;
- ULONG  henum;
- HWND   hwndNext, hwndParent = OSLIB_HWND_DESKTOP;
-
-  dprintf(("EnumThreadWindows\n"));
-
-  do {
-        henum = OSLibWinBeginEnumWindows(hwndParent);
-        while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
-        {
-                window = Win32BaseWindow::GetWindowFromOS2Handle(hwndNext);
-                if(window == NULL) {
-                        window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndNext);
-                        if(!window) {
-                            //OS/2 window or non-frame window, so skip it
-                            continue;
-                        }
-                }
-                if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE) {
-                        goto Abort;
-                }
-        }
-        if(hwndParent == OSLIB_HWND_OBJECT)
-                break;
-        hwndParent = OSLIB_HWND_OBJECT;
-        OSLibWinEndEnumWindows(henum);
-  }
-  while(TRUE);
-
-Abort:
-  OSLibWinEndEnumWindows(henum);
-  return TRUE;
+  return windowDesktop->EnumWindows(lpfn, lParam); 
 }
 //******************************************************************************
@@ -1453,8 +1391,12 @@
 HWND WIN32API GetLastActivePopup( HWND hWnd)
 {
-    dprintf(("USER32:  GetLastActivePopup"));
+ HWND hwnd;
+
     hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
 
-    return Win32BaseWindow::OS2ToWin32Handle(O32_GetLastActivePopup(hWnd));
+    hwnd = Win32BaseWindow::OS2ToWin32Handle(O32_GetLastActivePopup(hWnd));
+
+    dprintf(("GetLastActivePopup %x returned %x", hWnd, hwnd));
+    return hwnd;
 }
 //******************************************************************************
