Index: trunk/src/user32/new/menu.cpp
===================================================================
--- trunk/src/user32/new/menu.cpp	(revision 2441)
+++ trunk/src/user32/new/menu.cpp	(revision 2444)
@@ -1,3 +1,3 @@
-/* $Id: menu.cpp,v 1.9 2000-01-13 20:11:36 sandervl Exp $*/
+/* $Id: menu.cpp,v 1.10 2000-01-15 14:18:16 cbratschi Exp $*/
 /*
  * Menu functions
@@ -1029,15 +1029,5 @@
     //debug_print_menuitem("MENU_DrawMenuItem: ", lpitem, "");
 
-    if (lpitem->fType & MF_SYSMENU)
-    {
-        if( !IsIconic(hwnd) )
-        {
-          Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
-
-          if (win32wnd) win32wnd->DrawSysButton(hdc,lpitem->fState & (MF_HILITE | MF_MOUSESELECT));
-        }
-
-        return;
-    }
+    if (lpitem->fType & MF_SYSMENU) return;
 
     if (lpitem->fType & MF_OWNERDRAW)
@@ -1074,7 +1064,4 @@
 
     if ((lpitem->fState & MF_HILITE) && !(IS_BITMAP_ITEM(lpitem->fType)))
-        if (menuBar)
-            DrawEdge(hdc, &rect, BDR_SUNKENOUTER, BF_RECT);
-        else
             FillRect( hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT) );
     else {
@@ -1385,22 +1372,44 @@
     }
 
-    FillRect(hDC, lprect, GetSysColorBrush(COLOR_MENU) );
-
-    SelectObject( hDC, GetSysColorPen(COLOR_3DFACE));
-    MoveToEx( hDC, lprect->left, lprect->bottom,NULL);
-    LineTo( hDC, lprect->right, lprect->bottom );
+    HDC memDC;
+    HBITMAP memBmp,oldBmp;
+    RECT r;
+    HFONT oldMemFont;
+
+    memDC = CreateCompatibleDC(hDC);
+    r = *lprect;
+    r.right -= r.left;
+    r.bottom -= r.top;
+    r.left = r.top = 0;
+    memBmp = CreateCompatibleBitmap(hDC,r.right,r.bottom+1);
+    oldBmp = SelectObject(memDC,memBmp);
+    oldMemFont = SelectObject(memDC,hMenuFont);
+
+    FillRect(memDC,&r,GetSysColorBrush(COLOR_MENU));
+
+    SelectObject(memDC,GetSysColorPen(COLOR_3DFACE));
+    MoveToEx(memDC,r.left,r.bottom,NULL);
+    LineTo(memDC,r.right,r.bottom);
 
     if (lppop->nItems == 0)
     {
-        retvalue = GetSystemMetrics(SM_CYMENU);
-        goto END;
-    }
-
-    for (i = 0; i < lppop->nItems; i++)
-    {
+      retvalue = GetSystemMetrics(SM_CYMENU);
+    } else
+    {
+      for (i = 0; i < lppop->nItems; i++)
+      {
+        OffsetRect(&lppop->items[i].rect,-lprect->left,-lprect->top);
         MENU_DrawMenuItem( hwnd,getMenu(hwnd), GetWindow(hwnd,GW_OWNER),
-                         hDC, &lppop->items[i], lppop->Height, TRUE, ODA_DRAWENTIRE );
-    }
-    retvalue = lppop->Height;
+                         memDC, &lppop->items[i], lppop->Height, TRUE, ODA_DRAWENTIRE );
+        OffsetRect(&lppop->items[i].rect,lprect->left,lprect->top);
+      }
+      retvalue = lppop->Height;
+    }
+
+    BitBlt(hDC,lprect->left,lprect->top,lprect->right-lprect->left,lprect->bottom-lprect->top+1,memDC,0,0,SRCCOPY);
+    SelectObject(memDC,oldBmp);
+    if (oldMemFont) SelectObject(memDC,oldMemFont);
+    DeleteObject(memBmp);
+    DeleteDC(memDC);
 
 END:
@@ -2103,5 +2112,5 @@
  * Walks menu chain trying to find a menu pt maps to.
  */
-static HMENU MENU_PtMenu( HMENU hMenu, POINT pt )
+static HMENU MENU_PtMenu(HMENU hMenu,POINT pt,BOOL inMenuBar)
 {
    POPUPMENU *menu = (POPUPMENU*)hMenu;
@@ -2112,5 +2121,5 @@
           (menu->items[ht].fType & MF_POPUP) &&
           (menu->items[ht].fState & MF_MOUSESELECT))
-        ? (UINT) MENU_PtMenu(menu->items[ht].hSubMenu, pt) : 0;
+        ? (UINT) MENU_PtMenu(menu->items[ht].hSubMenu,pt,inMenuBar) : 0;
 
    if( !ht )    /* check the current window (avoiding WM_HITTEST) */
@@ -2126,6 +2135,6 @@
         else
         {
-            ht = ( ht == HTSYSMENU ) ? (UINT)(getSysMenu(menu->hWnd))
-                 : ( ht == HTMENU ) ? (UINT)(getMenu(menu->hWnd)) : 0;
+            ht = ((ht == HTSYSMENU) && !inMenuBar) ? (UINT)(getSysMenu(menu->hWnd))
+                 : ((ht == HTMENU) && inMenuBar) ? (UINT)(getMenu(menu->hWnd)) : 0;
         }
    }
@@ -2402,7 +2411,7 @@
         if( hNewWnd != pmt->hOwnerWnd )
         {
-            ReleaseCapture(); 
+            ReleaseCapture();
             pmt->hOwnerWnd = hNewWnd;
-	    SetCapture(pmt->hOwnerWnd); //SvL: Don't know if this is good enough
+            SetCapture(pmt->hOwnerWnd); //SvL: Don't know if this is good enough
             //EVENT_Capture( pmt->hOwnerWnd, HTMENU ); //CB: todo
         }
@@ -2568,6 +2577,5 @@
  * Menu tracking code.
  */
-static INT MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y,
-                              HWND hwnd, const RECT *lprect )
+static INT MENU_TrackMenu(HMENU hmenu,UINT wFlags,INT x,INT y,HWND hwnd,BOOL inMenuBar,const RECT *lprect)
 {
     MSG msg;
@@ -2606,5 +2614,5 @@
          * clear that menu loop is not over yet. */
 //        if (!GetMessageA(&msg,msg.hwnd,0,0)) break;
-	//SvL: Getting messages for only the menu delays background paints (i.e. VPBuddy logo)
+        //SvL: Getting messages for only the menu delays background paints (i.e. VPBuddy logo)
         if (!GetMessageA(&msg,0,0,0)) break;
         TranslateMessage( &msg );
@@ -2619,5 +2627,6 @@
             /* Find a menu for this mouse event */
             POINT pt = msg.pt;
-            hmenu = MENU_PtMenu( mt.hTopMenu, pt );
+
+            hmenu = MENU_PtMenu(mt.hTopMenu,pt,inMenuBar);
 
             switch(msg.message)
@@ -2828,5 +2837,5 @@
 void MENU_TrackMouseMenuBar( HWND hWnd, INT ht, POINT pt )
 {
-    HMENU hMenu = (ht == HTSYSMENU) ? getSysMenu(hWnd):getMenu(hWnd);
+    HMENU hMenu = (ht == 0) ? getMenu(hWnd):getSysMenu(hWnd);
     UINT wFlags = TPM_ENTERIDLEEX | TPM_BUTTONDOWN | TPM_LEFTALIGN | TPM_LEFTBUTTON;
 
@@ -2836,5 +2845,5 @@
     {
         MENU_InitTracking( hWnd, hMenu, FALSE, wFlags );
-        MENU_TrackMenu( hMenu, wFlags, pt.x, pt.y, hWnd, NULL );
+        MENU_TrackMenu( hMenu, wFlags, pt.x, pt.y, hWnd,ht == 0, NULL );
         MENU_ExitTracking(hWnd);
     }
@@ -2895,5 +2904,5 @@
                 PostMessageA( hWnd, WM_KEYDOWN, VK_DOWN, 0L );
 
-            MENU_TrackMenu( hTrackMenu, wFlags, 0, 0, hWnd, NULL );
+            MENU_TrackMenu( hTrackMenu, wFlags, 0, 0, hWnd,TRUE, NULL );
         }
 
@@ -2924,5 +2933,5 @@
 
     if (MENU_ShowPopup( hWnd, hMenu, 0, x, y, 0, 0 ))
-        ret = MENU_TrackMenu( hMenu, wFlags | TPM_POPUPMENU, 0, 0, hWnd, lpRect );
+        ret = MENU_TrackMenu( hMenu, wFlags | TPM_POPUPMENU, 0, 0, hWnd,FALSE, lpRect );
     MENU_ExitTracking(hWnd);
 
@@ -3311,10 +3320,10 @@
 
     if (IS_STRING_ITEM(flags) && str)
-    	dprintf(("USER32: InsertMenuA %x %d %x %d %s", hMenu, pos, flags, id, str));
+        dprintf(("USER32: InsertMenuA %x %d %x %d %s", hMenu, pos, flags, id, str));
     //    TRACE("hMenu %04x, pos %d, flags %08x, "
     //                  "id %04x, str '%s'\n",
     //                  hMenu, pos, flags, id, str );
     else // TRACE("hMenu %04x, pos %d, flags %08x, "
-    	dprintf(("USER32: InsertMenuA %x %d %x %d %x", hMenu, pos, flags, id, str));
+        dprintf(("USER32: InsertMenuA %x %d %x %d %x", hMenu, pos, flags, id, str));
     //                   "id %04x, str %08lx (not a string)\n",
     //                   hMenu, pos, flags, id, (DWORD)str );
@@ -3445,5 +3454,5 @@
     if (IS_STRING_ITEM(flags))
     {
-    	dprintf(("USER32: ModifyMenuA, %x %d %x %d %s", hMenu, pos, flags, id, str));
+        dprintf(("USER32: ModifyMenuA, %x %d %x %d %s", hMenu, pos, flags, id, str));
         //TRACE("%04x %d %04x %04x '%s'\n",
         //              hMenu, pos, flags, id, str ? str : "#NULL#" );
@@ -3452,5 +3461,5 @@
     else
     {
-    	dprintf(("USER32: ModifyMenuA, %x %d %x %d %x", hMenu, pos, flags, id, str));
+        dprintf(("USER32: ModifyMenuA, %x %d %x %d %x", hMenu, pos, flags, id, str));
         //TRACE("%04x %d %04x %04x %08lx\n",
         //              hMenu, pos, flags, id, (DWORD)str );
Index: trunk/src/user32/new/oslibwin.cpp
===================================================================
--- trunk/src/user32/new/oslibwin.cpp	(revision 2441)
+++ trunk/src/user32/new/oslibwin.cpp	(revision 2444)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.cpp,v 1.37 2000-01-14 14:45:16 sandervl Exp $ */
+/* $Id: oslibwin.cpp,v 1.38 2000-01-15 14:18:16 cbratschi Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -51,5 +51,5 @@
 HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
                           char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame,
-                          ULONG id, BOOL fTaskList)
+                          ULONG id, BOOL fTaskList,BOOL saveBits)
 {
  HWND  hwndClient;
@@ -75,4 +75,5 @@
 
   dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP | WS_CLIPSIBLINGS);
+  if (saveBits) dwWinStyle |= WS_SAVEBITS;
 
   dwFrameStyle |= FCF_NOBYTEALIGN;
@@ -92,5 +93,5 @@
 
   if (*hwndFrame) {
-    hwndClient = WinCreateWindow (*hwndFrame, WIN32_STDCLASS,
+    hwndClient = WinCreateWindow (*hwndFrame,saveBits ? WIN32_STDCLASS:WIN32_STDCLASS2,
                                   NULL, dwClientStyle, 0, 0, 0, 0,
                                   *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
Index: trunk/src/user32/new/oslibwin.h
===================================================================
--- trunk/src/user32/new/oslibwin.h	(revision 2441)
+++ trunk/src/user32/new/oslibwin.h	(revision 2444)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.h,v 1.30 2000-01-14 14:45:16 sandervl Exp $ */
+/* $Id: oslibwin.h,v 1.31 2000-01-15 14:18:17 cbratschi Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -39,5 +39,5 @@
 HWND  OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
                            char *pszName, HWND Owner, ULONG fBottom,
-                           HWND *hwndFrame, ULONG id, BOOL fTaskList);
+                           HWND *hwndFrame, ULONG id, BOOL fTaskList,BOOL saveBits);
 
 BOOL  OSLibWinConvertStyle(ULONG dwStyle, ULONG *dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle, ULONG *borderWidth, ULONG *borderHeight);
Index: trunk/src/user32/new/win32wbase.cpp
===================================================================
--- trunk/src/user32/new/win32wbase.cpp	(revision 2441)
+++ trunk/src/user32/new/win32wbase.cpp	(revision 2444)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.42 2000-01-14 17:48:32 cbratschi Exp $ */
+/* $Id: win32wbase.cpp,v 1.43 2000-01-15 14:18:17 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -530,5 +530,5 @@
                                  (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
                                  (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
-                                 &OS2HwndFrame, 0, fTaskList);
+                                 &OS2HwndFrame, 0, fTaskList,windowClass->getStyle() & CS_SAVEBITS);
   if(OS2Hwnd == 0) {
         dprintf(("Window creation failed!!"));
@@ -1504,4 +1504,6 @@
 
     case WM_NCRBUTTONUP:
+        return HandleNCRButtonUp(wParam,lParam);
+
     case WM_NCMBUTTONUP:
         return 0;
Index: trunk/src/user32/new/win32wbase.h
===================================================================
--- trunk/src/user32/new/win32wbase.h	(revision 2441)
+++ trunk/src/user32/new/win32wbase.h	(revision 2444)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.29 2000-01-14 17:48:33 cbratschi Exp $ */
+/* $Id: win32wbase.h,v 1.30 2000-01-15 14:18:18 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -385,4 +385,5 @@
         LONG  HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
         LONG  HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
+        LONG  HandleNCRButtonUp(WPARAM wParam,LPARAM lParam);
         BOOL  WindowNeedsWMBorder();
         VOID  AdjustRectOuter(LPRECT rect,BOOL menu);
@@ -393,11 +394,11 @@
 public:
         LONG  HandleNCHitTest(POINT pt);
-        BOOL  DrawSysButton(HDC hdc,BOOL down);
         BOOL  GetSysPopupPos(RECT* rect);
 private:
+        BOOL  DrawSysButton(HDC hdc,RECT *rect);
         BOOL  DrawGrayButton(HDC hdc,int x,int y);
-        VOID  DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed);
-        VOID  DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed);
-        VOID  DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed);
+        VOID  DrawCloseButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
+        VOID  DrawMaxButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
+        VOID  DrawMinButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
         VOID  DrawCaption(HDC hdc,RECT *rect,BOOL active,BOOL redrawText);
         VOID  UpdateCaptionText();
Index: trunk/src/user32/new/win32wbasenonclient.cpp
===================================================================
--- trunk/src/user32/new/win32wbasenonclient.cpp	(revision 2441)
+++ trunk/src/user32/new/win32wbasenonclient.cpp	(revision 2444)
@@ -1,3 +1,3 @@
-/* $Id: win32wbasenonclient.cpp,v 1.7 2000-01-14 17:48:33 cbratschi Exp $ */
+/* $Id: win32wbasenonclient.cpp,v 1.8 2000-01-15 14:18:18 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2 (non-client methods)
@@ -74,4 +74,7 @@
   WORD wStateChange;
 
+  //CB: only caption is changed on activation
+  if (!(dwStyle & WS_CAPTION)) return TRUE;
+
   if( wParam ) wStateChange = !(flags & WIN_NCACTIVATED);
   else wStateChange = flags & WIN_NCACTIVATED;
@@ -115,7 +118,7 @@
   hdc = GetWindowDC(Win32Hwnd);
   if (wParam == HTMINBUTTON)
-    DrawMinButton(hdc,TRUE,FALSE);
+    DrawMinButton(hdc,NULL,TRUE,FALSE);
   else
-    DrawMaxButton(hdc,TRUE,FALSE);
+    DrawMaxButton(hdc,NULL,TRUE,FALSE);
   do
   {
@@ -127,13 +130,13 @@
     {
       if (wParam == HTMINBUTTON)
-        DrawMinButton(hdc,pressed,FALSE);
+        DrawMinButton(hdc,NULL,pressed,FALSE);
       else
-        DrawMaxButton(hdc,pressed,FALSE);
+        DrawMaxButton(hdc,NULL,pressed,FALSE);
     }
   } while (msg.message != WM_LBUTTONUP);
   if (wParam == HTMINBUTTON)
-    DrawMinButton(hdc,FALSE,FALSE);
+    DrawMinButton(hdc,NULL,FALSE,FALSE);
   else
-    DrawMaxButton(hdc,FALSE,FALSE);
+    DrawMaxButton(hdc,NULL,FALSE,FALSE);
   ReleaseCapture();
   ReleaseDC(Win32Hwnd,hdc);
@@ -164,5 +167,5 @@
   hdc = GetWindowDC(Win32Hwnd);
   SetCapture(Win32Hwnd);
-  DrawCloseButton(hdc,TRUE,FALSE);
+  DrawCloseButton(hdc,NULL,TRUE,FALSE);
   do
   {
@@ -172,7 +175,7 @@
     pressed = (HandleNCHitTest(msg.pt) == wParam);
     if (pressed != oldstate)
-      DrawCloseButton(hdc, pressed, FALSE);
+      DrawCloseButton(hdc,NULL,pressed,FALSE);
   } while (msg.message != WM_LBUTTONUP);
-  DrawCloseButton(hdc,FALSE,FALSE);
+  DrawCloseButton(hdc,NULL,FALSE,FALSE);
   ReleaseCapture();
   ReleaseDC(Win32Hwnd,hdc);
@@ -244,10 +247,4 @@
       if(dwStyle & WS_SYSMENU )
       {
-        if( !(dwStyle & WS_MINIMIZE) )
-        {
-          HDC hDC = GetWindowDC(Win32Hwnd);
-          DrawSysButton(hDC,TRUE);
-          ReleaseDC(Win32Hwnd,hDC);
-        }
         SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTSYSMENU,lParam);
       }
@@ -606,12 +603,13 @@
 //******************************************************************************
 //******************************************************************************
-BOOL Win32BaseWindow::DrawSysButton(HDC hdc,BOOL down)
+BOOL Win32BaseWindow::DrawSysButton(HDC hdc,RECT *rect)
 {
   if(!(flags & WIN_MANAGED))
   {
     HICON  hIcon;
-    RECT rect;
-
-    GetInsideRect(&rect);
+    RECT r;
+
+    if (!rect) GetInsideRect(&r);
+    else r = *rect;
 
     hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
@@ -625,8 +623,8 @@
 
     if (hIcon)
-      DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
-                  GetSystemMetrics(SM_CXSMICON),
-                  GetSystemMetrics(SM_CYSMICON),
-                  0, 0, DI_NORMAL);
+      DrawIconEx(hdc,r.left+2,r.top+2,hIcon,
+                 GetSystemMetrics(SM_CXSMICON),
+                 GetSystemMetrics(SM_CYSMICON),
+                 0, 0, DI_NORMAL);
 
     return (hIcon != 0);
@@ -683,7 +681,7 @@
 //******************************************************************************
 //******************************************************************************
-VOID Win32BaseWindow::DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed)
-{
-  RECT rect;
+VOID Win32BaseWindow::DrawCloseButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
+{
+  RECT r;
   HDC hdcMem;
 
@@ -693,5 +691,6 @@
     HBITMAP hBmp, hOldBmp;
 
-    GetInsideRect(&rect);
+    if (!rect) GetInsideRect(&r);
+    else r = *rect;
 
     hdcMem = CreateCompatibleDC( hdc );
@@ -700,11 +699,11 @@
     GetObjectA (hBmp, sizeof(BITMAP), &bmp);
 
-    BitBlt (hdc, rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
-            rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
+    BitBlt (hdc, r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
+            r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
             bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
 
     if(bGrayed)
-      DrawGrayButton(hdc,rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
-                     rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
+      DrawGrayButton(hdc,r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
+                     r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
 
     SelectObject (hdcMem, hOldBmp);
@@ -714,7 +713,7 @@
 //******************************************************************************
 //******************************************************************************
-VOID Win32BaseWindow::DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed)
-{
-  RECT rect;
+VOID Win32BaseWindow::DrawMaxButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
+{
+  RECT r;
   HDC hdcMem;
 
@@ -724,5 +723,6 @@
     HBITMAP  hBmp,hOldBmp;
 
-    GetInsideRect(&rect);
+    if (!rect) GetInsideRect(&r);
+    else r = *rect;
     hdcMem = CreateCompatibleDC( hdc );
     hBmp = IsZoomed(Win32Hwnd) ?
@@ -733,13 +733,13 @@
 
     if (dwStyle & WS_SYSMENU)
-      rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
-
-    BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
-          rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
+      r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
+
+    BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
+          r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
           bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
 
     if(bGrayed)
-      DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
-                      rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
+      DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
+                      r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
 
 
@@ -750,7 +750,7 @@
 //******************************************************************************
 //******************************************************************************
-VOID Win32BaseWindow::DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed)
-{
-  RECT rect;
+VOID Win32BaseWindow::DrawMinButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed)
+{
+  RECT r;
   HDC hdcMem;
 
@@ -761,5 +761,6 @@
     HBITMAP  hBmp,hOldBmp;
 
-    GetInsideRect(&rect);
+    if (!rect) GetInsideRect(&r);
+    else r = *rect;
 
     hdcMem = CreateCompatibleDC( hdc );
@@ -769,17 +770,17 @@
 
     if (dwStyle & WS_SYSMENU)
-      rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
+      r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
 
     /* In win 95 there is always a Maximize box when there is a Minimize one */
     if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
-      rect.right += -1 - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2;
-
-    BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
-          rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
+      r.right -= bmp.bmWidth;
+
+    BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
+          r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
           bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
 
     if(bGrayed)
-      DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
-                      rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
+      DrawGrayButton(hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
+                      r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
 
 
@@ -793,14 +794,24 @@
 VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active,BOOL redrawText)
 {
-  RECT  r = *rect;
+  RECT  r = *rect,r2;
   char  buffer[256];
   HPEN  hPrevPen;
+  HDC memDC;
+  HBITMAP memBmp,oldBmp;
 
   if (flags & WIN_MANAGED) return;
 
-  hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) );
-  MoveToEx( hdc, r.left, r.bottom - 1, NULL );
-  LineTo( hdc, r.right, r.bottom - 1 );
-  SelectObject( hdc, hPrevPen );
+  memDC = CreateCompatibleDC(hdc);
+  r.right -= r.left;
+  r.bottom -= r.top;
+  r.left = r.top = 0;
+  r2 = r;
+  memBmp = CreateCompatibleBitmap(hdc,r.right,r.bottom);
+  oldBmp = SelectObject(memDC,memBmp);
+
+  hPrevPen = SelectObject(memDC,GetSysColorPen(COLOR_3DFACE));
+  MoveToEx(memDC,r.left,r.bottom-1,NULL);
+  LineTo(memDC,r.right,r.bottom-1);
+  SelectObject(memDC,hPrevPen);
   r.bottom--;
 
@@ -810,5 +821,5 @@
 
     if (startColor == endColor)
-      FillRect(hdc,&r,GetSysColorBrush(startColor));
+      FillRect(memDC,&r,GetSysColorBrush(startColor));
     else
     {
@@ -831,9 +842,9 @@
         r2.left = r2.right;
         r2.right = r.left+w*x/steps;
-        FillRect(hdc,&r2,brush);
+        FillRect(memDC,&r2,brush);
         DeleteObject(brush);
       }
     }
-  } else FillRect(hdc,&r,GetSysColorBrush(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION));
+  } else FillRect(memDC,&r,GetSysColorBrush(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION));
 
   if (!hbitmapClose)
@@ -851,5 +862,5 @@
   if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
   {
-    if (redrawText || DrawSysButton(hdc,FALSE))
+    if (redrawText || DrawSysButton(memDC,&r))
       r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
   }
@@ -865,5 +876,5 @@
 
       /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
-      DrawCloseButton(hdc, FALSE,
+      DrawCloseButton(memDC,&r2,FALSE,
                       ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
     }
@@ -876,9 +887,9 @@
 
       if (!redrawText)
-        DrawMaxButton(hdc, FALSE, (!(dwStyle & WS_MAXIMIZEBOX)));
+        DrawMaxButton(memDC,&r2,FALSE,(!(dwStyle & WS_MAXIMIZEBOX)));
       r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
 
       if (!redrawText)
-        DrawMinButton(hdc, FALSE,  (!(dwStyle & WS_MINIMIZEBOX)));
+        DrawMinButton(memDC,&r2,FALSE,  (!(dwStyle & WS_MINIMIZEBOX)));
       r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     }
@@ -889,4 +900,5 @@
     NONCLIENTMETRICSA nclm;
     HFONT hFont, hOldFont;
+
     nclm.cbSize = sizeof(NONCLIENTMETRICSA);
     SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
@@ -895,12 +907,17 @@
     else
       hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
-    hOldFont = SelectObject (hdc, hFont);
-    SetTextColor(hdc,GetSysColor(active ? COLOR_CAPTIONTEXT:COLOR_INACTIVECAPTIONTEXT));
-    SetBkMode( hdc, TRANSPARENT );
+    hOldFont = SelectObject (memDC, hFont);
+    SetTextColor(memDC,GetSysColor(active ? COLOR_CAPTIONTEXT:COLOR_INACTIVECAPTIONTEXT));
+    SetBkMode(memDC, TRANSPARENT );
     r.left += 2;
-    DrawTextA( hdc, buffer, -1, &r,
+    DrawTextA(memDC, buffer, -1, &r,
              DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
-    DeleteObject (SelectObject (hdc, hOldFont));
-  }
+    DeleteObject (SelectObject (memDC, hOldFont));
+  }
+
+  BitBlt(hdc,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top,memDC,0,0,SRCCOPY);
+  SelectObject(memDC,oldBmp);
+  DeleteObject(memBmp);
+  DeleteDC(memDC);
 }
 //******************************************************************************
@@ -1054,5 +1071,5 @@
     r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
 
-    rect.top += MENU_DrawMenuBar( hdc, &r, Win32Hwnd, suppress_menupaint ) + 1;
+    rect.top += MENU_DrawMenuBar(hdc,&r,Win32Hwnd,suppress_menupaint)+1;
   }
 
@@ -1168,4 +1185,21 @@
   return 0;
 }
+//******************************************************************************
+//******************************************************************************
+LONG Win32BaseWindow::HandleNCRButtonUp(WPARAM wParam,LPARAM lParam)
+{
+  if (wParam == HTCAPTION)
+  {
+    if (GetActiveWindow() != Win32Hwnd)
+        SetActiveWindow();
+
+    if ((GetActiveWindow() == Win32Hwnd) && (dwStyle & WS_SYSMENU))
+    {
+      SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTCAPTION,lParam);
+    }
+  }
+
+  return 0;
+}
 /***********************************************************************
  *           NC_HandleSysCommand
@@ -1173,5 +1207,4 @@
  * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
  *
- * TODO: Not done (see #if 0)
  */
 LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam,POINT *pt32)
@@ -1179,8 +1212,4 @@
     UINT uCommand = wParam & 0xFFF0;
 
-/* //CB: don't need this, perhaps recycle for menus
-    if ((getStyle() & WS_CHILD) && (uCommand != SC_KEYMENU))
-        ScreenToClient(getParent()->getWindowHandle(), pt32 );
-*/
     switch (uCommand)
     {
Index: trunk/src/user32/new/winprop.cpp
===================================================================
--- trunk/src/user32/new/winprop.cpp	(revision 2441)
+++ trunk/src/user32/new/winprop.cpp	(revision 2444)
@@ -1,3 +1,3 @@
-/* $Id: winprop.cpp,v 1.3 2000-01-01 14:57:39 cbratschi Exp $ */
+/* $Id: winprop.cpp,v 1.4 2000-01-15 14:18:18 cbratschi Exp $ */
 /*
  * Win32 Property apis for OS/2
@@ -43,5 +43,5 @@
 {
 #ifdef DEBUG
-    WriteLog("USER32:  EnumPropsExW\n");
+    WriteLog("USER32:  EnumPropsExW DOES NOT WORK\n");
 #endif
     // NOTE: This will not work as is (needs UNICODE support)
@@ -55,5 +55,5 @@
 {
 #ifdef DEBUG
-    WriteLog("USER32:  EnumPropsW\n");
+    WriteLog("USER32:  EnumPropsW DOES NOT WORK\n");
 #endif
     // NOTE: This will not work as is (needs UNICODE support)
@@ -72,5 +72,5 @@
     if(!window) {
         dprintf(("GetPropA, window %x not found", hwnd));
-	SetLastError(ERROR_INVALID_WINDOW_HANDLE);
+        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
         return 0;
     }
@@ -109,5 +109,5 @@
     if(!window) {
         dprintf(("RemovePropA, window %x not found", hwnd));
-	SetLastError(ERROR_INVALID_WINDOW_HANDLE);
+        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
         return 0;
     }
@@ -145,5 +145,5 @@
     if(!window) {
         dprintf(("SetPropA, window %x not found", hwnd));
-	SetLastError(ERROR_INVALID_WINDOW_HANDLE);
+        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
         return 0;
     }
