Index: trunk/src/user32/new/menu.cpp
===================================================================
--- trunk/src/user32/new/menu.cpp	(revision 2456)
+++ trunk/src/user32/new/menu.cpp	(revision 2458)
@@ -1,3 +1,3 @@
-/* $Id: menu.cpp,v 1.10 2000-01-15 14:18:16 cbratschi Exp $*/
+/* $Id: menu.cpp,v 1.11 2000-01-16 18:17:10 cbratschi Exp $*/
 /*
  * Menu functions
@@ -104,4 +104,5 @@
 #define TPM_BUTTONDOWN          0x40000000              /* menu was clicked before tracking */
 #define TPM_POPUPMENU           0x20000000              /* menu is a popup menu */
+#define TPM_CAPTIONSYSMENU      0x10000000
 
   /* popup menu shade thickness */
@@ -2014,5 +2015,5 @@
  */
 static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
-                                  BOOL selectFirst, UINT wFlags )
+                                  BOOL selectFirst, UINT wFlags,POINT *pt)
 {
     RECT rect;
@@ -2071,8 +2072,16 @@
         MENU_InitSysMenuPopup(item->hSubMenu,GetWindowLongA(menu->hWnd,GWL_STYLE), GetClassLongA(menu->hWnd, GCL_STYLE));
 
-        if (win32wnd) win32wnd->GetSysPopupPos(&rect);
-        rect.top = rect.bottom;
-        rect.right = GetSystemMetrics(SM_CXSIZE);
-        rect.bottom = GetSystemMetrics(SM_CYSIZE);
+        if ((wFlags & TPM_CAPTIONSYSMENU) && pt)
+        {
+          rect.top = pt->y;
+          rect.left = pt->x;
+          rect.bottom = rect.right = 0;
+        } else
+        {
+          if (win32wnd) win32wnd->GetSysPopupPos(&rect);
+          rect.top = rect.bottom;
+          rect.right = GetSystemMetrics(SM_CXSIZE);
+          rect.bottom = GetSystemMetrics(SM_CYSIZE);
+        }
     }
     else
@@ -2185,5 +2194,5 @@
     }
     else
-        pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hMenu, TRUE, wFlags);
+        pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hMenu, TRUE, wFlags,&pmt->pt);
 
     return -1;
@@ -2243,5 +2252,5 @@
             if(!(item->fState & MF_MOUSESELECT ))
             {
-                pmt->hCurrentMenu = MENU_ShowSubPopup( pmt->hOwnerWnd, hPtMenu, FALSE, wFlags );
+                pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,hPtMenu,FALSE,wFlags,&pmt->pt);
             }
 
@@ -2321,5 +2330,5 @@
     {
             MENU_SwitchTracking( pmt, hPtMenu, id );
-            pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hPtMenu, FALSE, wFlags);
+            pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hPtMenu, FALSE, wFlags,&pmt->pt);
     }
     return TRUE;
@@ -2510,5 +2519,5 @@
             if( !MENU_SuspendPopup( pmt, WM_KEYDOWN ) )
                 pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,
-                                                pmt->hTopMenu, TRUE, wFlags);
+                                                pmt->hTopMenu, TRUE, wFlags,&pmt->pt);
         }
     }
@@ -2538,5 +2547,5 @@
 
         hmenutmp = pmt->hCurrentMenu;
-        pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hmenutmp, TRUE, wFlags);
+        pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hmenutmp, TRUE, wFlags,&pmt->pt);
 
         /* if subpopup was displayed then we are done */
@@ -2568,5 +2577,5 @@
             if( !MENU_SuspendPopup(pmt, WM_KEYDOWN) )
                 pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,
-                                                       pmt->hTopMenu, TRUE, wFlags);
+                                                       pmt->hTopMenu, TRUE, wFlags,&pmt->pt);
     }
 }
@@ -2697,5 +2706,5 @@
                     menu = (POPUPMENU*)mt.hCurrentMenu;
                     if (!(menu->wFlags & MF_POPUP))
-                        mt.hCurrentMenu = MENU_ShowSubPopup(mt.hOwnerWnd, mt.hTopMenu, TRUE, wFlags);
+                        mt.hCurrentMenu = MENU_ShowSubPopup(mt.hOwnerWnd, mt.hTopMenu, TRUE, wFlags,&mt.pt);
                     else      /* otherwise try to move selection */
                         MENU_MoveSelection( mt.hOwnerWnd, mt.hCurrentMenu, ITEM_NEXT );
@@ -2844,4 +2853,7 @@
     if (IsMenu(hMenu))
     {
+        if (ht == HTCAPTION) wFlags |= TPM_CAPTIONSYSMENU;
+        if (IsIconic(hWnd)) wFlags |= TPM_BOTTOMALIGN; //CB: todo: for minimized windows
+
         MENU_InitTracking( hWnd, hMenu, FALSE, wFlags );
         MENU_TrackMenu( hMenu, wFlags, pt.x, pt.y, hWnd,ht == 0, NULL );
Index: trunk/src/user32/new/oslibwin.cpp
===================================================================
--- trunk/src/user32/new/oslibwin.cpp	(revision 2456)
+++ trunk/src/user32/new/oslibwin.cpp	(revision 2458)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.cpp,v 1.38 2000-01-15 14:18:16 cbratschi Exp $ */
+/* $Id: oslibwin.cpp,v 1.39 2000-01-16 18:17:11 cbratschi Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -996,6 +996,7 @@
 void OSLibWinShowTaskList(HWND hwndFrame)
 {
-  WinPostMsg(NULLHANDLE, WM_SYSCOMMAND, (MPARAM)SC_TASKMANAGER, MPFROM2SHORT(CMDSRC_MENU, TRUE));
-}
-//******************************************************************************
-//******************************************************************************
+  //CB: don't know if this works on all machines
+  WinSetActiveWindow(HWND_DESKTOP,0x8000000E);
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/user32/new/pmframe.cpp
===================================================================
--- trunk/src/user32/new/pmframe.cpp	(revision 2456)
+++ trunk/src/user32/new/pmframe.cpp	(revision 2458)
@@ -1,3 +1,3 @@
-/* $Id: pmframe.cpp,v 1.17 2000-01-14 13:16:57 sandervl Exp $ */
+/* $Id: pmframe.cpp,v 1.18 2000-01-16 18:17:11 cbratschi Exp $ */
 /*
  * Win32 Frame Managment Code for OS/2
@@ -118,4 +118,13 @@
       {
         win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
+
+        RECT rect;
+
+        rect.left = rect.top = rect.right = rect.bottom = 0;
+        win32wnd->AdjustMaximizedRect(&rect);
+        swp->x += rect.left;
+        swp->cx += rect.right-rect.left;
+        swp->y -= rect.bottom;
+        swp->cy += rect.bottom-rect.top;
       }
       else if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
@@ -131,5 +140,12 @@
 
     case WM_QUERYBORDERSIZE:
-      goto RunDefFrameProc;
+    {
+      PWPOINT size = (PWPOINT)mp1;
+
+      size->x = 0;
+      size->y = 0;
+      RestoreOS2TIB();
+      return (MRESULT)TRUE;
+    }
 
     case WM_BUTTON1DOWN:
@@ -212,5 +228,5 @@
         if(!win32wnd->CanReceiveSizeMsgs())
            break;
-//CB: todo: adjust maximized window rect (how does WINE it?)
+
         WinQueryWindowPos(hwnd, &swpOld);
         if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
@@ -263,5 +279,5 @@
         if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
         {
-        	goto RunDefFrameProc;
+                goto RunDefFrameProc;
         }
 
@@ -276,12 +292,12 @@
         OSLibMapSWPtoWINDOWPOSFrame(pswp, &wp, &swpOld, hParent, hwnd);
 
-	if(pswp->fl & SWP_ACTIVATE)
-	{
+        if(pswp->fl & SWP_ACTIVATE)
+        {
              WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
-	}
-
-        if(pswp->fl & (SWP_MOVE | SWP_SIZE))
-        {
-	  //Note: Also updates the new window rectangle
+        }
+
+        if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
+        {
+          //Note: Also updates the new window rectangle
           win32wnd->MsgFormatFrame(&wp);
 
@@ -325,5 +341,5 @@
             {
               WinInvalidateRect(hwnd,NULL,TRUE);
-            } 
+            }
             else
             {
@@ -360,5 +376,5 @@
             }
           }
-        } 
+        }
         else
         {
@@ -378,5 +394,5 @@
 
     case WM_ERASEBACKGROUND:
-	break;
+        break;
 
     case WM_CALCVALIDRECTS:
@@ -453,11 +469,11 @@
   SWP swpClient = {0};
 
-	rectOld = *win32wnd->getClientRectPtr();
+        rectOld = *win32wnd->getClientRectPtr();
         win32wnd->MsgFormatFrame(NULL);
         rectNew = *win32wnd->getClientRectPtr();
         if(WinEqualRect(0, (PRECTL)&rectOld, (PRECTL)&rectNew) == 1) {
-		WinInvalidateRect(win32wnd->getOS2FrameWindowHandle(), NULL, FALSE);
-		return;
-	} 
+                WinInvalidateRect(win32wnd->getOS2FrameWindowHandle(), NULL, FALSE);
+                return;
+        }
         //CB: todo: use result for WM_CALCVALIDRECTS
         mapWin32ToOS2Rect(win32wnd->getOS2FrameWindowHandle(), win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
Index: trunk/src/user32/new/scroll.cpp
===================================================================
--- trunk/src/user32/new/scroll.cpp	(revision 2456)
+++ trunk/src/user32/new/scroll.cpp	(revision 2458)
@@ -1,3 +1,3 @@
-/* $Id: scroll.cpp,v 1.11 2000-01-13 20:11:37 sandervl Exp $ */
+/* $Id: scroll.cpp,v 1.12 2000-01-16 18:17:11 cbratschi Exp $ */
 /*
  * Scrollbar control
@@ -73,10 +73,7 @@
 static BOOL SCROLL_MovingThumb = FALSE;
 
-// Get the infoPtr: works only with scrollbar handles
-
 static SCROLLBAR_INFO *SCROLL_GetInfoPtr( HWND hwnd, INT nBar )
 {
     Win32BaseWindow *win32wnd;
-    HWND hwndFrame;
 
     switch(nBar)
Index: trunk/src/user32/new/win32wbase.cpp
===================================================================
--- trunk/src/user32/new/win32wbase.cpp	(revision 2456)
+++ trunk/src/user32/new/win32wbase.cpp	(revision 2458)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.43 2000-01-15 14:18:17 cbratschi Exp $ */
+/* $Id: win32wbase.cpp,v 1.44 2000-01-16 18:17:12 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -1123,4 +1123,5 @@
       {
         horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
+        if (!horzScrollInfo) break;
         horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
         horzScrollInfo->MaxVal = 100;
@@ -1133,4 +1134,5 @@
       {
         vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
+        if (!vertScrollInfo) break;
         vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
         vertScrollInfo->MaxVal = 100;
@@ -1406,10 +1408,10 @@
                 point.x = rectClient.left;
                 point.y = rectClient.top;
-                MapWindowPoints(getWindowHandle(), getParent()->getWindowHandle(), &point, 1);
+                ClientToScreen(getParent()->getWindowHandle(),&point);
 
                 lParam = MAKELONG(point.x, point.y);
             }
             else {//in screen coordinates
-                lParam = MAKELONG(rectWindow.left+rectClient.left, rectWindow.top+rectClient.top);
+                lParam = MAKELONG(rectClient.left,rectClient.top);
             }
             SendInternalMessageA(WM_MOVE, 0, lParam);
Index: trunk/src/user32/new/win32wbase.h
===================================================================
--- trunk/src/user32/new/win32wbase.h	(revision 2456)
+++ trunk/src/user32/new/win32wbase.h	(revision 2458)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.30 2000-01-15 14:18:18 cbratschi Exp $ */
+/* $Id: win32wbase.h,v 1.31 2000-01-16 18:17:12 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -428,4 +428,6 @@
          fakeOpen32WinBaseClass fakeWinBase;
 
+         VOID  AdjustMaximizedRect(LPRECT rect);
+
          BOOL   isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
          HDC    getOwnDC() { return ownDC; }
Index: trunk/src/user32/new/win32wbasenonclient.cpp
===================================================================
--- trunk/src/user32/new/win32wbasenonclient.cpp	(revision 2456)
+++ trunk/src/user32/new/win32wbasenonclient.cpp	(revision 2458)
@@ -1,3 +1,3 @@
-/* $Id: win32wbasenonclient.cpp,v 1.12 2000-01-15 17:27:20 sandervl Exp $ */
+/* $Id: win32wbasenonclient.cpp,v 1.13 2000-01-16 18:17:13 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2 (non-client methods)
@@ -317,8 +317,6 @@
 //******************************************************************************
 //******************************************************************************
-VOID Win32BaseWindow::AdjustRectOuter(LPRECT rect,BOOL menu)
-{
-  if(dwStyle & WS_ICONIC) return;
-
+VOID Win32BaseWindow::AdjustMaximizedRect(LPRECT rect)
+{
   /* Decide if the window will be managed (see CreateWindowEx) */
   //if (!WindowNeedsWMBorder()) //CB: check Options.managed
@@ -332,4 +330,23 @@
         if (HAS_THINFRAME( dwStyle ))
           InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
+  }
+}
+//******************************************************************************
+//******************************************************************************
+VOID Win32BaseWindow::AdjustRectOuter(LPRECT rect,BOOL menu)
+{
+  if(dwStyle & WS_ICONIC) return;
+
+  /* Decide if the window will be managed (see CreateWindowEx) */
+  //if (!WindowNeedsWMBorder()) //CB: check Options.managed
+  {
+    if (HAS_THICKFRAME(dwStyle,dwExStyle ))
+      InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
+    else
+      if (HAS_DLGFRAME( dwStyle, dwExStyle ))
+        InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
+      else
+        if (HAS_THINFRAME( dwStyle ))
+          InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
 
     if ((dwStyle & WS_CAPTION) == WS_CAPTION)
@@ -367,4 +384,6 @@
   LONG result = 0;
   UINT style;
+
+    dprintf(("Default WM_NCCALCSIZE handler"));
 
     if (!calcValidRects) return 0;
@@ -408,7 +427,7 @@
   RECT rect = rectWindow;
 
+  if (dwStyle & WS_MINIMIZE) return HTCAPTION;
+
   if (!PtInRect(&rect,pt)) return HTNOWHERE;
-
-  if (dwStyle & WS_MINIMIZE) return HTCAPTION;
 
   if (!(flags & WIN_MANAGED))
@@ -1197,13 +1216,18 @@
 LONG Win32BaseWindow::HandleNCRButtonUp(WPARAM wParam,LPARAM lParam)
 {
-  if (wParam == HTCAPTION)
-  {
-    if (GetActiveWindow() != Win32Hwnd)
+  switch(wParam)
+  {
+    case HTCAPTION:
+      if (GetActiveWindow() != Win32Hwnd)
         SetActiveWindow();
 
-    if ((GetActiveWindow() == Win32Hwnd) && (dwStyle & WS_SYSMENU))
-    {
-      SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTCAPTION,lParam);
-    }
+      if ((GetActiveWindow() == Win32Hwnd) && (dwStyle & WS_SYSMENU))
+      {
+        SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTCAPTION,lParam);
+      }
+      break;
+
+    default:
+      break;
   }
 
@@ -1225,5 +1249,7 @@
     case SC_SIZE:
     {
-      DWORD flags = 0;
+      DWORD flags;
+
+      if (dwStyle & WS_MAXIMIZE) break;
 
       switch ((wParam & 0xF)+2)
@@ -1260,4 +1286,8 @@
           flags = TFOS_BOTTOM | TFOS_RIGHT;
           break;
+
+        default:
+          flags = TFOS_BOTTOM | TFOS_RIGHT;
+          break;
       }
       if (flags) FrameTrackFrame(this,flags);
@@ -1266,4 +1296,5 @@
 
     case SC_MOVE:
+        if (dwStyle & WS_MAXIMIZE) break;
         FrameTrackFrame(this,TFOS_MOVE);
         break;
