Index: trunk/src/user32/dc.cpp
===================================================================
--- trunk/src/user32/dc.cpp	(revision 2675)
+++ trunk/src/user32/dc.cpp	(revision 2676)
@@ -1,3 +1,3 @@
-/* $Id: dc.cpp,v 1.43 2000-02-06 22:00:22 sandervl Exp $ */
+/* $Id: dc.cpp,v 1.44 2000-02-07 14:30:18 sandervl Exp $ */
 
 /*
@@ -77,4 +77,5 @@
 int  WIN32API ReleaseDC(HWND hwnd, HDC hdc);
 BOOL WIN32API PostMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+int  WIN32API ExtSelectClipRgn(HDC hdc, HRGN hrgn, int fnMode);
 
 //******************************************************************************
@@ -437,4 +438,104 @@
 //******************************************************************************
 //******************************************************************************
+#if 1
+HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)
+{
+   HWND     hwnd = hWnd ? hWnd : HWND_DESKTOP;
+   pDCData  pHps = NULLHANDLE;
+   RECTL    rect;
+   HPS      hPS_ownDC = NULLHANDLE;
+
+   if ( !lpps )
+   {
+      O32_SetLastError (ERROR_INVALID_PARAMETER);
+      return (HDC)NULLHANDLE;
+   }
+
+   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
+
+#if 0
+   if ((hwnd != HWND_DESKTOP) && wnd->isOwnDC())
+   {
+        hPS_ownDC = wnd->getOwnDC();
+        //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
+        if(hPS_ownDC) {
+                pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
+                if (!pHps)
+                {
+                        O32_SetLastError (ERROR_INVALID_PARAMETER);
+                        return (HDC)NULLHANDLE;
+                }
+        }
+   }
+#endif
+
+   HWND hwndClient = wnd->getOS2WindowHandle();
+   HPS  hps = WinBeginPaint(hwndClient, hPS_ownDC, &rect);
+
+   if (!pHps)
+   {
+      HDC hdc = HPSToHDC (hwndClient, hps, NULL, NULL);
+      pHps = (pDCData)GpiQueryDCData(hps);
+   }
+
+   if (hPS_ownDC == 0)
+      setMapMode (wnd, pHps, MM_TEXT_W);
+   else
+      setPageXForm (wnd, pHps);
+
+   pHps->hdcType = TYPE_3;
+   lpps->hdc = (HDC)hps;
+
+   if(!wnd->isSuppressErase()) {
+        wnd->setSuppressErase(TRUE);
+        wnd->setEraseBkgnd (FALSE, !wnd->MsgEraseBackGround(lpps->hdc));
+   }
+   lpps->fErase = wnd->isPSErase();
+
+   if (!hPS_ownDC)
+   {
+      long height  = wnd->getClientHeight();
+      rect.yTop    = height - rect.yTop;
+      rect.yBottom = height - rect.yBottom;
+   }
+   else
+   {
+      rect.yTop--;
+      rect.yBottom--;
+      GpiConvert(pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rect);
+   }
+
+   WINRECT_FROM_PMRECT(lpps->rcPaint, rect);
+   dprintf(("USER32: BeginPaint %x -> hdc %x (%d,%d)(%d,%d)", hWnd, pHps->hps, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom));
+
+   O32_SetLastError(0);
+   return (HDC)pHps->hps;
+}
+
+BOOL WIN32API EndPaint (HWND hwnd, const PAINTSTRUCT_W *pPaint)
+{
+ pDCData pHps;
+
+   dprintf (("USER32: EndPaint(%x)", hwnd));
+
+   if (!pPaint || !pPaint->hdc )
+      return TRUE;
+
+   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
+
+   if (!wnd) goto exit;
+
+   //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
+   pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);
+   if (pHps && (pHps->hdcType == TYPE_3)) {
+          WinEndPaint (pHps->hps);
+   }
+   wnd->setSuppressErase(FALSE);
+
+exit:
+   O32_SetLastError(0);
+   return TRUE;
+}
+#else
 HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)
 {
@@ -563,5 +664,4 @@
 		GpiDestroyRegion(pHps->hps, hrgnOld);
 	}
-	//todo restore old clip region for CS_OWNDC windows
    	if(hwnd == HWND_DESKTOP || !wnd->isOwnDC()) {
 		ReleaseDC(hwnd, pPaint->hdc);
@@ -587,4 +687,5 @@
    return TRUE;
 }
+#endif
 //******************************************************************************
 //******************************************************************************
@@ -710,4 +811,6 @@
 // DCX_EXCLUDERGN (complex regions allowed)
 // DCX_INTERSECTRGN (complex regions allowed)
+//
+//TODO: WM_SETREDRAW affects drawingAllowed flag!!
 //******************************************************************************
 HDC WIN32API GetDCEx (HWND hwnd, HRGN hrgn, ULONG flags)
@@ -806,13 +909,4 @@
          goto error;
 
-      BytesNeeded = O32_GetRegionData (hrgn, 0, NULL);
-      RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
-      if (RgnData == NULL)
-          goto error;
-      O32_GetRegionData (hrgn, BytesNeeded, RgnData);
-
-      i = RgnData->rdh.nCount;
-      pr = (PRECT)(RgnData->Buffer);
-
       success = TRUE;
       if (flags & DCX_EXCLUDERGN_W)
@@ -820,4 +914,14 @@
 #if 0 //CB: todo
 	 long height;
+
+      	 BytesNeeded = GetRegionData (hrgn, 0, NULL);
+      	 RgnData = (PRGNDATA_W)_alloca (BytesNeeded);
+      	 if (RgnData == NULL)
+          	goto error;
+      	 GetRegionData (hrgn, BytesNeeded, RgnData);
+
+      	 i = RgnData->rdh.nCount;
+      	 pr = (PRECT)(RgnData->Buffer);
+
          if (flags & DCX_WINDOW_W)
 		height = wnd->getWindowHeight();
@@ -835,5 +939,7 @@
       else //DCX_INTERSECTRGN_W
       {
-        O32_SelectClipRgn(pHps->hps,hrgn); //CB: works so far
+         if(ExtSelectClipRgn(pHps->hps, hrgn, RGN_AND_W) == ERROR_W) {
+		dprintf(("ExtSelectClipRgn failed!!"));
+	 }
       }
       if (!success)
@@ -846,4 +952,5 @@
    pHps->psType  = psType;
    pHps->hdcType = TYPE_1;
+   //TODO: WM_SETREDRAW affects drawingAllowed flag!!
    GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF);
 
@@ -980,17 +1087,8 @@
    if (redraw & RDW_UPDATENOW_W) redraw &= ~RDW_ERASENOW_W;
 
-   if (redraw & RDW_NOERASE_W || !(redraw & (RDW_ERASE_W|RDW_ERASENOW_W))) {
+   if (redraw & RDW_NOERASE_W) {
       	wnd->setSuppressErase(TRUE);
    }
    else	wnd->setSuppressErase(FALSE);
-
-//   if (redraw & RDW_NOERASE_W)
-//      wnd->setEraseBkgnd (FALSE);
-
-//SvL: Test
-//   if (redraw & RDW_UPDATENOW_W)
-//      wnd->setSuppressErase (FALSE);
-//   else if (redraw & RDW_ERASENOW_W)
-//      wnd->setSuppressErase (FALSE);
 
    if (hrgn)
Index: trunk/src/user32/oslibwin.cpp
===================================================================
--- trunk/src/user32/oslibwin.cpp	(revision 2675)
+++ trunk/src/user32/oslibwin.cpp	(revision 2676)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.cpp,v 1.67 2000-02-05 19:45:16 cbratschi Exp $ */
+/* $Id: oslibwin.cpp,v 1.68 2000-02-07 14:30:18 sandervl Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -51,9 +51,10 @@
 HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
                           char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame,
-                          ULONG id, BOOL fTaskList,BOOL fShellPosition,BOOL saveBits)
+                          ULONG id, BOOL fTaskList,BOOL fShellPosition,
+                          int classStyle)
 {
  HWND  hwndClient;
 
-  dprintf(("WinCreateWindow %x %s", hwndParent, pszName));
+  dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle));
 
   if(pszName && *pszName == 0) {
@@ -73,6 +74,8 @@
   FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
 
+  if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
+  if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
+
   dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP | WS_CLIPSIBLINGS);
-  if (saveBits) dwWinStyle |= WS_SAVEBITS;
 
   dwFrameStyle |= FCF_NOBYTEALIGN;
@@ -93,5 +96,5 @@
 
   if (*hwndFrame) {
-    hwndClient = WinCreateWindow (*hwndFrame,saveBits ? WIN32_STDCLASS2:WIN32_STDCLASS,
+    hwndClient = WinCreateWindow (*hwndFrame, (classStyle & CS_SAVEBITS_W) ? WIN32_STDCLASS2:WIN32_STDCLASS,
                                   NULL, dwClientStyle, 0, 0, 0, 0,
                                   *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
Index: trunk/src/user32/oslibwin.h
===================================================================
--- trunk/src/user32/oslibwin.h	(revision 2675)
+++ trunk/src/user32/oslibwin.h	(revision 2676)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.h,v 1.38 2000-02-05 19:45:16 cbratschi Exp $ */
+/* $Id: oslibwin.h,v 1.39 2000-02-07 14:30:18 sandervl Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -40,5 +40,5 @@
 HWND  OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
                            char *pszName, HWND Owner, ULONG fBottom,
-                           HWND *hwndFrame, ULONG id, BOOL fTaskList,BOOL fShellPosition,BOOL saveBits);
+                           HWND *hwndFrame, ULONG id, BOOL fTaskList,BOOL fShellPosition, int classStyle);
 
 BOOL  OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle);
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 2675)
+++ trunk/src/user32/win32wbase.cpp	(revision 2676)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.156 2000-02-06 22:00:24 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.157 2000-02-07 14:30:18 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -531,5 +531,5 @@
                                  (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
                                  (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
-                                 &OS2HwndFrame, 0, fTaskList, 0, windowClass->getStyle() & CS_SAVEBITS);
+                                 &OS2HwndFrame, 0, fTaskList, 0, windowClass->getStyle());
   if(OS2Hwnd == 0) {
         dprintf(("Window creation failed!!"));
@@ -1338,4 +1338,5 @@
       return 0;
 
+    dprintf(("MsgNCPaint (%d,%d)(%d,%d)", rect.left, rect.top, rect.right, rect.bottom));
     hrgn = CreateRectRgnIndirect(&rect);
     if (!hrgn) return 0;
