Index: trunk/src/user32/dc.cpp
===================================================================
--- trunk/src/user32/dc.cpp	(revision 5141)
+++ trunk/src/user32/dc.cpp	(revision 5146)
@@ -1,3 +1,3 @@
-/* $Id: dc.cpp,v 1.83 2001-02-01 18:02:20 sandervl Exp $ */
+/* $Id: dc.cpp,v 1.84 2001-02-17 14:49:25 sandervl Exp $ */
 
 /*
@@ -1374,8 +1374,15 @@
    }
    else dprintf(("InvalidateRect %x NULL erase=%d", hwnd, erase));
+#if 1
+   result = RedrawWindow (hwnd, pRect, NULLHANDLE,
+                          RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
+                          (erase ? RDW_ERASE_W : 0) |
+                          (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
+#else
    result = RedrawWindow (hwnd, pRect, NULLHANDLE,
                           RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
                           (erase ? RDW_ERASE_W : RDW_NOERASE_W) |
                           (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
+#endif
    return (result);
 }
@@ -1387,8 +1394,15 @@
 
    dprintf(("InvalidateRgn %x %x erase=%d", hwnd, hrgn, erase));
+#if 1
+   result = RedrawWindow (hwnd, NULL, hrgn,
+                          RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
+                          (erase ? RDW_ERASE_W : 0) |
+                          (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
+#else
    result = RedrawWindow (hwnd, NULL, hrgn,
                           RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
                           (erase ? RDW_ERASE_W : RDW_NOERASE_W) |
                           (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
+#endif
    return (result);
 }
Index: trunk/src/user32/pmwindow.cpp
===================================================================
--- trunk/src/user32/pmwindow.cpp	(revision 5141)
+++ trunk/src/user32/pmwindow.cpp	(revision 5146)
@@ -1,3 +1,3 @@
-/* $Id: pmwindow.cpp,v 1.113 2001-02-15 00:33:01 sandervl Exp $ */
+/* $Id: pmwindow.cpp,v 1.114 2001-02-17 14:49:26 sandervl Exp $ */
 /*
  * Win32 Window Managment Code for OS/2
@@ -222,5 +222,5 @@
   else
   if(msg == WIN32APP_SETFOCUSMSG) {
-      //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing; 
+      //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
       //must delay this function call
       //mp1 = win32 window handle
@@ -379,13 +379,7 @@
             {
                 //Only send PM WM_ACTIVATE to top-level windows (frame windows)
-                if(!(WinQueryWindowUShort(hwnd,QWS_FLAGS) & FF_ACTIVE))
+                if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & FF_ACTIVE))
                 {
-                    if(isFrame) {
                         WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
-                    }
-                    else
-                    if(win32wnd->IsWindowCreated()) {
-                        win32wnd->MsgActivate(1, 0, win32wnd->getWindowHandle(), hwnd);
-                    }
                 }
             }
@@ -501,5 +495,5 @@
         {
              //Only send PM WM_ACTIVATE to top-level windows (frame windows)
-             if(!(WinQueryWindowUShort(hwnd,QWS_FLAGS) & FF_ACTIVE))
+             if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & FF_ACTIVE))
              {
                 if(isFrame) {
@@ -519,9 +513,9 @@
     case WM_ACTIVATE:
     {
-        USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
+        USHORT flags = WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS);
 
         dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
 
-        WinSetWindowUShort(hwnd,QWS_FLAGS, SHORT1FROMMP(mp1) ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
+        WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
         if(win32wnd->IsWindowCreated())
         {
@@ -596,8 +590,8 @@
     {
       HWND hwndFocus = (HWND)mp1;
-       
+
         dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2));
 
-        //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing; 
+        //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
         //must delay this function call
 
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 5141)
+++ trunk/src/user32/win32wbase.cpp	(revision 5146)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.234 2001-02-10 10:31:31 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.235 2001-02-17 14:49:26 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -494,4 +494,9 @@
         return FALSE;
     }
+    if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32FLAGS, 0) == FALSE) {
+        dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
+        SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
+        return FALSE;
+    }
 
     if (HOOK_IsHooked( WH_CBT ))
@@ -706,8 +711,8 @@
             if (getStyle() & (WS_MINIMIZE | WS_MAXIMIZE))
             {
-		        RECT newPos;
-		        UINT swFlag = (getStyle() & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
+                        RECT newPos;
+                        UINT swFlag = (getStyle() & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
                 setStyle(getStyle() & ~(WS_MAXIMIZE | WS_MINIMIZE));
-		        MinMaximize(swFlag, &newPos);
+                        MinMaximize(swFlag, &newPos);
                 swFlag = ((getStyle() & WS_CHILD) || GetActiveWindow()) ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
                                                                         : SWP_NOZORDER | SWP_FRAMECHANGED;
@@ -2683,7 +2688,10 @@
 {
     if(getParent()) {
-          return getParent()->getWindowHandle() == hwndParent;
-    }
-    else  return 0;
+         if(getParent()->getWindowHandle() == hwndParent)
+             return TRUE;
+
+         return getParent()->IsChild(hwndParent);
+    }
+    else return 0;
 }
 //******************************************************************************
@@ -3460,72 +3468,4 @@
 //  dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
     return 0;
-}
-//******************************************************************************
-//******************************************************************************
-HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
-{
- Win32BaseWindow *child, *nextchild, *lastchild;
- HWND retvalue;
-
-    if (hwndCtrl)
-    {
-        child = GetWindowFromHandle(hwndCtrl);
-        if (!child)
-        {
-            retvalue = 0;
-            goto END;
-        }
-        /* Make sure hwndCtrl is a top-level child */
-        while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
-        {
-            child = child->getParent();
-            if(child == NULL) break;
-        }
-
-        if (!child || (child->getParent() != this))
-        {
-            retvalue = 0;
-            goto END;
-        }
-    }
-    else
-    {
-        /* No ctrl specified -> start from the beginning */
-        child = (Win32BaseWindow *)getFirstChild();
-        if (!child)
-        {
-            retvalue = 0;
-            goto END;
-        }
-
-        if (!fPrevious)
-        {
-            while (child->getNextChild())
-            {
-                child = (Win32BaseWindow *)child->getNextChild();
-            }
-        }
-    }
-
-    lastchild = child;
-    nextchild = (Win32BaseWindow *)child->getNextChild();
-    while (TRUE)
-    {
-        if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
-
-        if (child == nextchild) break;
-
-        if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
-            !(nextchild->getStyle() & WS_DISABLED))
-        {
-            lastchild = nextchild;
-            if (!fPrevious) break;
-        }
-        nextchild = (Win32BaseWindow *)nextchild->getNextChild();
-    }
-    retvalue = lastchild->getWindowHandle();
-
-END:
-    return retvalue;
 }
 //******************************************************************************
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 5141)
+++ trunk/src/user32/win32wbase.h	(revision 5146)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.104 2001-02-15 00:33:01 sandervl Exp $ */
+/* $Id: win32wbase.h,v 1.105 2001-02-17 14:49:26 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -27,5 +27,6 @@
 #define OFFSET_WIN32WNDPTR        0
 #define OFFSET_WIN32PM_MAGIC      4
-#define NROF_WIN32WNDBYTES        8
+#define OFFSET_WIN32FLAGS         8
+#define NROF_WIN32WNDBYTES        12
 
 #define WIN32PM_MAGIC           0x12345678
@@ -291,5 +292,4 @@
            BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
 
-         HWND   getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
          HWND   getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
 
Index: trunk/src/user32/windlg.cpp
===================================================================
--- trunk/src/user32/windlg.cpp	(revision 5141)
+++ trunk/src/user32/windlg.cpp	(revision 5146)
@@ -1,3 +1,3 @@
-/* $Id: windlg.cpp,v 1.20 2001-02-05 18:49:30 sandervl Exp $ */
+/* $Id: windlg.cpp,v 1.21 2001-02-17 14:49:26 sandervl Exp $ */
 /*
  * Win32 dialog apis for OS/2
@@ -241,4 +241,93 @@
     return (BOOL)SendDlgItemMessageA(hwnd, id,BM_GETCHECK,0,0);
 }
+/***********************************************************************
+ *           DIALOG_GetNextTabItem
+ *
+ * Helper for GetNextDlgTabItem
+ */
+static HWND DIALOG_GetNextTabItem( HWND hwndMain, HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious )
+{
+    LONG dsStyle;
+    LONG exStyle;
+    UINT wndSearch = fPrevious ? GW_HWNDPREV : GW_HWNDNEXT;
+    HWND retWnd = 0;
+    HWND hChildFirst = 0;
+
+    if(!hwndCtrl) 
+    {
+        hChildFirst = GetWindow(hwndDlg,GW_CHILD);
+        if(fPrevious) hChildFirst = GetWindow(hChildFirst,GW_HWNDLAST);
+    }
+    else
+    {
+        HWND hParent = GetParent(hwndCtrl);
+        BOOL bValid = FALSE;
+        while( hParent)
+        {
+            if(hParent == hwndMain)
+            {
+                bValid = TRUE;
+                break;
+            }
+            hParent = GetParent(hParent);
+        }
+        if(bValid)
+        {
+            hChildFirst = GetWindow(hwndCtrl,wndSearch);
+            if(!hChildFirst)
+            {
+                if(GetParent(hwndCtrl) != hwndMain)
+                    hChildFirst = GetWindow(GetParent(hwndCtrl),wndSearch);
+                else
+                {
+                    if(fPrevious)
+                        hChildFirst = GetWindow(hwndCtrl,GW_HWNDLAST);
+                    else
+                        hChildFirst = GetWindow(hwndCtrl,GW_HWNDFIRST);
+                }
+            }
+        }	
+    }
+    while(hChildFirst)
+    {
+        BOOL bCtrl = FALSE;
+        while(hChildFirst)
+        {
+            dsStyle = GetWindowLongA(hChildFirst,GWL_STYLE);
+            exStyle = GetWindowLongA(hChildFirst,GWL_EXSTYLE);
+            if( (dsStyle & DS_CONTROL || exStyle & WS_EX_CONTROLPARENT) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
+            {
+                bCtrl=TRUE;
+                break;
+            }
+            else if( (dsStyle & WS_TABSTOP) && (dsStyle & WS_VISIBLE) && !(dsStyle & WS_DISABLED))
+                break;
+            hChildFirst = GetWindow(hChildFirst,wndSearch);
+        }
+        if(hChildFirst)
+        {
+            if(bCtrl)
+                retWnd = DIALOG_GetNextTabItem(hwndMain,hChildFirst,(HWND)NULL,fPrevious );
+            else
+                retWnd = hChildFirst;
+        }
+        if(retWnd) break;
+        hChildFirst = GetWindow(hChildFirst,wndSearch);
+    }
+    if(!retWnd && hwndCtrl)
+    {
+        HWND hParent = GetParent(hwndCtrl);
+        while(hParent)
+	{
+            if(hParent == hwndMain) break;
+            retWnd = DIALOG_GetNextTabItem(hwndMain,GetParent(hParent),hParent,fPrevious );
+            if(retWnd) break;
+            hParent = GetParent(hParent);
+	}
+        if(!retWnd)
+            retWnd = DIALOG_GetNextTabItem(hwndMain,hwndMain,(HWND)NULL,fPrevious );
+    }
+    return retWnd;
+}
 //******************************************************************************
 //******************************************************************************
@@ -253,6 +342,6 @@
         return 0;
     }
-    dprintf(("USER32:  GetNextDlgTabItem\n"));
-    return window->getNextDlgTabItem(hwndCtrl, fPrevious);
+    dprintf(("USER32: GetNextDlgTabItem %x %x %d", hwndDlg,hwndCtrl,fPrevious));
+    return DIALOG_GetNextTabItem(hwndDlg,hwndDlg,hwndCtrl,fPrevious); 
 }
 //******************************************************************************
