[User32]
authorJames Tabor <james.tabor@reactos.org>
Mon, 14 Apr 2014 01:52:37 +0000 (01:52 +0000)
committerJames Tabor <james.tabor@reactos.org>
Mon, 14 Apr 2014 01:52:37 +0000 (01:52 +0000)
- Cleanup and plug in. Removed code that is not used, this code served us well. An assessment is needed to be made, base on speed and necessity, on what stays or moved or duplicated.
- See CORE-7447.

svn path=/trunk/; revision=62745

reactos/win32ss/user/user32/windows/defwnd.c

index 3745999..5b90e29 100644 (file)
@@ -153,32 +153,6 @@ UserGetInsideRectNC(PWND Wnd, RECT *rect)
     }
 }
 
-#if 0
-VOID
-DefWndSetRedraw(HWND hWnd, WPARAM wParam)
-{
-    LONG Style = GetWindowLongPtr(hWnd, GWL_STYLE);
-    /* Content can be redrawn after a change. */
-    if (wParam)
-    {
-       if (!(Style & WS_VISIBLE)) /* Not Visible */
-       {
-          SetWindowLongPtr(hWnd, GWL_STYLE, WS_VISIBLE);
-       }
-    }
-    else /* Content cannot be redrawn after a change. */
-    {
-       if (Style & WS_VISIBLE) /* Visible */
-       {
-            RedrawWindow( hWnd, NULL, 0, RDW_ALLCHILDREN | RDW_VALIDATE );
-            Style &= ~WS_VISIBLE;
-            SetWindowLongPtr(hWnd, GWL_STYLE, Style); /* clear bits */
-       }
-    }
-    return;
-}
-#endif
-
 LRESULT
 DefWndHandleSetCursor(HWND hWnd, WPARAM wParam, LPARAM lParam, ULONG Style)
 {
@@ -255,502 +229,6 @@ DefWndHandleSetCursor(HWND hWnd, WPARAM wParam, LPARAM lParam, ULONG Style)
   return((LRESULT)SetCursor(LoadCursorW(0, IDC_ARROW)));
 }
 
-static LONG
-DefWndStartSizeMove(HWND hWnd, PWND Wnd, WPARAM wParam, POINT *capturePoint)
-{
-  LONG hittest = 0;
-  POINT pt;
-  MSG msg;
-  RECT rectWindow;
-  ULONG Style = Wnd->style;
-
-  rectWindow = Wnd->rcWindow;
-
-  if ((wParam & 0xfff0) == SC_MOVE)
-    {
-      /* Move pointer at the center of the caption */
-      RECT rect;
-      UserGetInsideRectNC(Wnd, &rect);
-      if (Style & WS_SYSMENU)
-       rect.left += GetSystemMetrics(SM_CXSIZE) + 1;
-      if (Style & WS_MINIMIZEBOX)
-       rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
-      if (Style & WS_MAXIMIZEBOX)
-       rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
-      //pt.x = rectWindow.left + (rect.right - rect.left) / 2;
-      //pt.y = rectWindow.top + rect.top + GetSystemMetrics(SM_CYSIZE)/2;
-      pt.x = (rect.right + rect.left) / 2;
-      pt.y = rect.top + GetSystemMetrics(SM_CYSIZE)/2;
-      ERR("SC_MOVE\n");
-      hittest = HTCAPTION;
-      *capturePoint = pt;
-    }
-  else  /* SC_SIZE */
-    {
-      pt.x = pt.y = 0;
-      while(!hittest)
-       {
-          if (!GetMessageW(&msg, NULL, 0, 0)) break; //return 0;
-          if (CallMsgFilterW( &msg, MSGF_SIZE )) continue;
-
-         switch(msg.message)
-           {
-           case WM_MOUSEMOVE:
-             //// Clamp the mouse position to the window rectangle when starting a window resize.
-              //pt.x = min( max( msg.pt.x, rectWindow.left ), rectWindow.right - 1 );
-              //pt.y = min( max( msg.pt.y, rectWindow.top ), rectWindow.bottom - 1 );
-              //// Breaks a win test.
-             hittest = DefWndNCHitTest(hWnd, msg.pt);
-             if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) hittest = 0;
-             break;
-
-           case WM_LBUTTONUP:
-             return 0;
-
-           case WM_KEYDOWN:
-             switch(msg.wParam)
-               {
-               case VK_UP:
-                 hittest = HTTOP;
-                 pt.x =(rectWindow.left+rectWindow.right)/2;
-                 pt.y = rectWindow.top + GetSystemMetrics(SM_CYFRAME) / 2;
-                 break;
-               case VK_DOWN:
-                 hittest = HTBOTTOM;
-                 pt.x =(rectWindow.left+rectWindow.right)/2;
-                 pt.y = rectWindow.bottom - GetSystemMetrics(SM_CYFRAME) / 2;
-                 break;
-               case VK_LEFT:
-                 hittest = HTLEFT;
-                 pt.x = rectWindow.left + GetSystemMetrics(SM_CXFRAME) / 2;
-                 pt.y =(rectWindow.top+rectWindow.bottom)/2;
-                 break;
-               case VK_RIGHT:
-                 hittest = HTRIGHT;
-                 pt.x = rectWindow.right - GetSystemMetrics(SM_CXFRAME) / 2;
-                 pt.y =(rectWindow.top+rectWindow.bottom)/2;
-                 break;
-               case VK_RETURN:
-               case VK_ESCAPE:
-                 return 0;
-               }
-            default:
-              TranslateMessage( &msg );
-              DispatchMessageW( &msg );
-              break;
-           }
-       }
-      *capturePoint = pt;
-    }
-    SetCursorPos( pt.x, pt.y );
-    DefWndHandleSetCursor(hWnd, (WPARAM)hWnd, MAKELONG(hittest, WM_MOUSEMOVE), Style);
-    //SendMessageW(hWnd, WM_SETCURSOR, (WPARAM)hWnd, MAKELONG(hittest, WM_MOUSEMOVE));
-    return hittest;
-}
-
-#define ON_LEFT_BORDER(hit) \
- (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
-#define ON_RIGHT_BORDER(hit) \
- (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
-#define ON_TOP_BORDER(hit) \
- (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
-#define ON_BOTTOM_BORDER(hit) \
- (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
-
-static VOID
-UserDrawWindowFrame(HDC hdc, const RECT *rect,
-                   ULONG width, ULONG height)
-{
-  HBRUSH hbrush = SelectObject( hdc, gpsi->hbrGray );
-
-  PatBlt( hdc, rect->left, rect->top,
-         rect->right - rect->left - width, height, PATINVERT );
-  PatBlt( hdc, rect->left, rect->top + height, width,
-         rect->bottom - rect->top - height, PATINVERT );
-  PatBlt( hdc, rect->left + width, rect->bottom - 1,
-         rect->right - rect->left - width, -height, PATINVERT );
-  PatBlt( hdc, rect->right - 1, rect->top, -width,
-         rect->bottom - rect->top - height, PATINVERT );
-  SelectObject( hdc, hbrush );
-}
-
-static VOID
-UserDrawMovingFrame(HDC hdc, RECT *rect, BOOL thickframe)
-{
-  if(thickframe)
-  {
-    UserDrawWindowFrame(hdc, rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME));
-  }
-  else
-  {
-    UserDrawWindowFrame(hdc, rect, 1, 1);
-  }
-}
-
-static VOID
-DefWndDoSizeMove(HWND hwnd, WORD wParam)
-{
-  HRGN DesktopRgn;
-  MSG msg;
-  RECT sizingRect, mouseRect, origRect, clipRect, unmodRect;
-  HDC hdc;
-  LONG hittest = (LONG)(wParam & 0x0f);
-  HCURSOR hDragCursor = 0, hOldCursor = 0;
-  POINT minTrack, maxTrack;
-  POINT capturePoint, pt;
-  ULONG Style, ExStyle;
-  BOOL thickframe;
-  BOOL iconic;
-  BOOL moved = FALSE;
-  DWORD dwPoint = GetMessagePos();
-  BOOL DragFullWindows = FALSE;
-  HWND hWndParent = NULL;
-  PWND Wnd;
-  WPARAM syscommand = wParam & 0xfff0;
-  HMONITOR mon = 0;
-
-  Wnd = ValidateHwnd(hwnd);
-  if (!Wnd)
-      return;
-
-  Style = Wnd->style;
-  ExStyle = Wnd->ExStyle;
-  iconic = (Style & WS_MINIMIZE) != 0;
-
-  //
-  // Show window contents while dragging the window, get flag from registry data.
-  //
-  SystemParametersInfoW(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
-
-  pt.x = GET_X_LPARAM(dwPoint);
-  pt.y = GET_Y_LPARAM(dwPoint);
-  capturePoint = pt;
-
-  TRACE("hwnd %p command %04lx, hittest %d, pos %d,%d\n",
-         hwnd, syscommand, hittest, pt.x, pt.y);
-
-  if ((Style & WS_MAXIMIZE) || !IsWindowVisible(hwnd)) return;
-
-  thickframe = UserHasThickFrameStyle(Style, ExStyle) && !iconic;
-
-  if (syscommand == SC_MOVE)
-  {
-      ERR("SC_MOVE\n");
-      if (!hittest) hittest = DefWndStartSizeMove(hwnd, Wnd, wParam, &capturePoint);
-      if (!hittest) return;
-  }
-  else  /* SC_SIZE */
-  {
-      if (!thickframe) return;
-      if (hittest && (syscommand != SC_MOUSEMENU))
-       {
-          hittest += (HTLEFT - WMSZ_LEFT);
-       }
-      else
-       {
-         SetCapture(hwnd);
-         hittest = DefWndStartSizeMove(hwnd, Wnd, wParam, &capturePoint);
-         if (!hittest)
-         {
-             ReleaseCapture();
-             return;
-         }
-      }
-  }
-
-  /* Get min/max info */
-
-  WinPosGetMinMaxInfo(hwnd, NULL, NULL, &minTrack, &maxTrack);
-  sizingRect = Wnd->rcWindow;
-  ERR("x %d y %d X %d Y %d\n",pt.x,pt.y,sizingRect.left,sizingRect.top);
-  if (Style & WS_CHILD)
-  {
-      hWndParent = GetParent(hwnd);
-      MapWindowPoints( 0, hWndParent, (LPPOINT)&sizingRect, 2 );
-      unmodRect = sizingRect;
-      GetClientRect(hWndParent, &mouseRect );
-      clipRect = mouseRect;
-      MapWindowPoints(hWndParent, HWND_DESKTOP, (LPPOINT)&clipRect, 2);
-  }
-  else
-  {
-      if(!(ExStyle & WS_EX_TOPMOST))
-      {
-        SystemParametersInfoW(SPI_GETWORKAREA, 0, &clipRect, 0);
-        mouseRect = clipRect;
-      }
-      else
-      {
-        SetRect(&mouseRect, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
-        clipRect = mouseRect;
-      }
-      mon = MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST );
-      unmodRect = sizingRect;
-  }
-  ClipCursor(&clipRect);
-
-  origRect = sizingRect;
-  if (ON_LEFT_BORDER(hittest))
-  {
-      mouseRect.left  = max( mouseRect.left, sizingRect.right-maxTrack.x );
-      mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x );
-  }
-  else if (ON_RIGHT_BORDER(hittest))
-  {
-      mouseRect.left  = max( mouseRect.left, sizingRect.left+minTrack.x );
-      mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x );
-  }
-  if (ON_TOP_BORDER(hittest))
-  {
-      mouseRect.top    = max( mouseRect.top, sizingRect.bottom-maxTrack.y );
-      mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y);
-  }
-  else if (ON_BOTTOM_BORDER(hittest))
-  {
-      mouseRect.top    = max( mouseRect.top, sizingRect.top+minTrack.y );
-      mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y );
-  }
-  if (Style & WS_CHILD)
-  {
-      MapWindowPoints( hWndParent, 0, (LPPOINT)&mouseRect, 2 );
-  }
-
-  IntNotifyWinEvent( EVENT_SYSTEM_MOVESIZESTART, hwnd, OBJID_WINDOW, CHILDID_SELF, 0);
-  SendMessageW( hwnd, WM_ENTERSIZEMOVE, 0, 0 );
-  NtUserxSetGUIThreadHandle(MSQ_STATE_MOVESIZE, hwnd);
-  if (GetCapture() != hwnd) SetCapture( hwnd );
-
-  if (Style & WS_CHILD)
-  {
-      /* Retrieve a default cache DC (without using the window style) */
-      hdc = GetDCEx(hWndParent, 0, DCX_CACHE);
-      DesktopRgn = NULL;
-  }
-  else
-  {
-      hdc = GetDC( 0 );
-      DesktopRgn = CreateRectRgnIndirect(&clipRect);
-  }
-
-  SelectObject(hdc, DesktopRgn);
-
-  if( iconic ) /* create a cursor for dragging */
-  {
-      HICON hIcon = (HICON)GetClassLongPtrW(hwnd, GCL_HICON);
-      if(!hIcon) hIcon = (HICON)SendMessageW( hwnd, WM_QUERYDRAGICON, 0, 0L);
-      if( hIcon ) hDragCursor = CursorIconToCursor( hIcon, TRUE );
-      if( !hDragCursor ) iconic = FALSE;
-  }
-
-  /* invert frame if WIN31_LOOK to indicate mouse click on caption */
-  if( !iconic && !DragFullWindows)
-  {
-      UserDrawMovingFrame( hdc, &sizingRect, thickframe);
-  }
-
-  for(;;)
-  {
-      int dx = 0, dy = 0;
-
-      if (!GetMessageW(&msg, 0, 0, 0)) break;
-      if (CallMsgFilterW( &msg, MSGF_SIZE )) continue;
-
-      /* Exit on button-up, Return, or Esc */
-      if ((msg.message == WM_LBUTTONUP) ||
-         ((msg.message == WM_KEYDOWN) &&
-          ((msg.wParam == VK_RETURN) || (msg.wParam == VK_ESCAPE)))) break;
-
-      if (msg.message == WM_PAINT)
-      {
-         if(!iconic && !DragFullWindows) UserDrawMovingFrame( hdc, &sizingRect, thickframe );
-         UpdateWindow( msg.hwnd );
-         if(!iconic && !DragFullWindows) UserDrawMovingFrame( hdc, &sizingRect, thickframe );
-         continue;
-      }
-
-      if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
-      {
-         TranslateMessage( &msg );
-         DispatchMessageW( &msg );
-         continue;  /* We are not interested in other messages */
-      }
-
-      pt = msg.pt;
-
-      if (msg.message == WM_KEYDOWN) switch(msg.wParam)
-      {
-       case VK_UP:    pt.y -= 8; break;
-       case VK_DOWN:  pt.y += 8; break;
-       case VK_LEFT:  pt.x -= 8; break;
-       case VK_RIGHT: pt.x += 8; break;
-      }
-
-      pt.x = max( pt.x, mouseRect.left );
-      pt.x = min( pt.x, mouseRect.right - 1 );
-      pt.y = max( pt.y, mouseRect.top );
-      pt.y = min( pt.y, mouseRect.bottom - 1 );
-
-      if (!hWndParent)
-      {
-          HMONITOR newmon;
-          MONITORINFO info;
-
-          if ((newmon = MonitorFromPoint( pt, MONITOR_DEFAULTTONULL )))
-              mon = newmon;
-
-          info.cbSize = sizeof(info);
-          if (mon && GetMonitorInfoW( mon, &info ))
-          {
-              pt.x = max( pt.x, info.rcWork.left );
-              pt.x = min( pt.x, info.rcWork.right - 1 );
-              pt.y = max( pt.y, info.rcWork.top );
-              pt.y = min( pt.y, info.rcWork.bottom - 1 );
-          }
-      }
-
-      dx = pt.x - capturePoint.x;
-      dy = pt.y - capturePoint.y;
-
-      if (dx || dy)
-      {
-         if( !moved )
-         {
-             moved = TRUE;
-
-               if( iconic ) /* ok, no system popup tracking */
-               {
-                   hOldCursor = SetCursor(hDragCursor);
-                   ShowCursor( TRUE );
-               }
-         }
-
-         if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
-         else
-         {
-             RECT newRect = unmodRect;
-
-             if (hittest == HTCAPTION) OffsetRect( &newRect, dx, dy );
-             if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
-             else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
-             if (ON_TOP_BORDER(hittest)) newRect.top += dy;
-             else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
-             if(!iconic && !DragFullWindows) UserDrawMovingFrame( hdc, &sizingRect, thickframe );
-             capturePoint = pt;
-
-             /* determine the hit location */
-             unmodRect = newRect;
-              if (syscommand == SC_SIZE)
-              {
-                  WPARAM wpSizingHit = 0;
-
-                  if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT)
-                      wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT);
-                  SendMessageW( hwnd, WM_SIZING, wpSizingHit, (LPARAM)&newRect );
-              }
-              else
-                  SendMessageW( hwnd, WM_MOVING, 0, (LPARAM)&newRect );
-
-             if (!iconic)
-               {
-                 if(!DragFullWindows)
-                   UserDrawMovingFrame( hdc, &newRect, thickframe );
-                 else
-                 { /* To avoid any deadlocks, all the locks on the windows
-                      structures must be suspended before the SetWindowPos */
-                    //ERR("SWP 1\n");
-                   SetWindowPos( hwnd, 0, newRect.left, newRect.top,
-                                 newRect.right - newRect.left,
-                                 newRect.bottom - newRect.top,
-                                 ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
-                 }
-               }
-             sizingRect = newRect;
-         }
-      }
-  }
-
-  ReleaseCapture();
-  ClipCursor(NULL);
-  if( iconic )
-  {
-      if( moved ) /* restore cursors, show icon title later on */
-      {
-         ShowCursor( FALSE );
-         SetCursor( hOldCursor );
-      }
-      DestroyCursor( hDragCursor );
-  }
-  else if(!DragFullWindows)
-      UserDrawMovingFrame( hdc, &sizingRect, thickframe );
-
-  if (Style & WS_CHILD)
-    ReleaseDC( hWndParent, hdc );
-  else
-  {
-    ReleaseDC( 0, hdc );
-    if(DesktopRgn)
-    {
-      DeleteObject(DesktopRgn);
-    }
-  }
-  //// This causes the mdi child window to jump up when it is moved.
-  //if (hWndParent) MapWindowPoints( 0, hWndParent, (POINT *)&sizingRect, 2 );
-
-  if (ISITHOOKED(WH_CBT))
-  {
-      LRESULT lResult;
-      NtUserMessageCall( hwnd, WM_CBT, HCBT_MOVESIZE, (LPARAM)&sizingRect, (ULONG_PTR)&lResult, FNID_DEFWINDOWPROC, FALSE);
-      if (lResult) moved = FALSE;
-  }
-
-  NtUserxSetGUIThreadHandle(MSQ_STATE_MOVESIZE, NULL);
-  SendMessageW( hwnd, WM_EXITSIZEMOVE, 0, 0 );
-  SendMessageW( hwnd, WM_SETVISIBLE, !IsIconic(hwnd), 0L);
-
-  /* window moved or resized */
-  if (moved)
-  {
-      /* if the moving/resizing isn't canceled call SetWindowPos
-       * with the new position or the new size of the window
-       */
-      if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
-      {
-         /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
-         if(!DragFullWindows )//|| iconic) breaks 2 win tests.
-         {
-           //ERR("SWP 2\n");
-           SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
-                         sizingRect.right - sizingRect.left,
-                         sizingRect.bottom - sizingRect.top,
-                         ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
-          }
-      }
-      else
-      { /* restore previous size/position */
-       if(DragFullWindows)
-       {
-         //ERR("SWP 3\n");
-         SetWindowPos( hwnd, 0, origRect.left, origRect.top,
-                       origRect.right - origRect.left,
-                       origRect.bottom - origRect.top,
-                       ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
-        }
-      }
-  }
-
-  if( IsWindow(hwnd) )
-    if( iconic )
-    {
-       /* Single click brings up the system menu when iconized */
-       if( !moved )
-        {
-           if( Style & WS_SYSMENU )
-             SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, MAKELONG(pt.x,pt.y));
-        }
-    }
-}
-
-
 /***********************************************************************
  *           DefWndTrackScrollBar
  *
@@ -785,7 +263,6 @@ LRESULT WINAPI DoAppSwitch( WPARAM wParam, LPARAM lParam);
 LRESULT
 DefWndHandleSysCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
 {
-//  WINDOWPLACEMENT wp;
   POINT Pt;
   LRESULT lResult;
 
@@ -801,8 +278,9 @@ DefWndHandleSysCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
     {
       case SC_MOVE:
       case SC_SIZE:
-       DefWndDoSizeMove(hWnd, wParam);
+       NtUserMessageCall( hWnd, WM_SYSCOMMAND, wParam, lParam, (ULONG_PTR)&lResult, FNID_DEFWINDOWPROC, FALSE);
        break;
+
     case SC_MINIMIZE:
         if (hWnd == GetActiveWindow())
             ShowOwnedPopups(hWnd,FALSE);
@@ -823,6 +301,7 @@ DefWndHandleSysCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
 
       case SC_CLOSE:
         return SendMessageW(hWnd, WM_CLOSE, 0, 0);
+
 //      case SC_DEFAULT:
       case SC_MOUSEMENU:
         {
@@ -887,65 +366,6 @@ DefWndHandleSysCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
 
   return(0);
 }
-#if 0 // Move to Win32k
-LRESULT
-DefWndHandleWindowPosChanging(HWND hWnd, WINDOWPOS* Pos)
-{
-    POINT maxTrack, minTrack;
-    LONG style = GetWindowLongPtrA(hWnd, GWL_STYLE);
-
-    if (Pos->flags & SWP_NOSIZE) return 0;
-    if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0))
-    {
-        WinPosGetMinMaxInfo(hWnd, NULL, NULL, &minTrack, &maxTrack);
-        Pos->cx = min(Pos->cx, maxTrack.x);
-        Pos->cy = min(Pos->cy, maxTrack.y);
-        if (!(style & WS_MINIMIZE))
-        {
-            if (Pos->cx < minTrack.x) Pos->cx = minTrack.x;
-            if (Pos->cy < minTrack.y) Pos->cy = minTrack.y;
-        }
-    }
-    else
-    {
-        Pos->cx = max(Pos->cx, 0);
-        Pos->cy = max(Pos->cy, 0);
-    }
-    return 0;
-}
-
-LRESULT
-DefWndHandleWindowPosChanged(HWND hWnd, WINDOWPOS* Pos)
-{
-  RECT Rect;
-
-  GetClientRect(hWnd, &Rect);
-  MapWindowPoints(hWnd, (GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CHILD ?
-                         GetParent(hWnd) : NULL), (LPPOINT) &Rect, 2);
-
-  if (! (Pos->flags & SWP_NOCLIENTMOVE))
-    {
-      SendMessageW(hWnd, WM_MOVE, 0, MAKELONG(Rect.left, Rect.top));
-    }
-
-  if (! (Pos->flags & SWP_NOCLIENTSIZE))
-    {
-      WPARAM wp = SIZE_RESTORED;
-      if (IsZoomed(hWnd))
-        {
-          wp = SIZE_MAXIMIZED;
-        }
-      else if (IsIconic(hWnd))
-        {
-          wp = SIZE_MINIMIZED;
-        }
-      SendMessageW(hWnd, WM_SIZE, wp,
-                   MAKELONG(Rect.right - Rect.left, Rect.bottom - Rect.top));
-    }
-
-  return 0;
-}
-#endif
 
 /***********************************************************************
  *           DefWndControlColor
@@ -1032,7 +452,7 @@ LRESULT FASTCALL
 DefWndSetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam)
 {
     HICON hIcon, hIconSmall, hIconOld;
+
     if ( wParam > ICON_SMALL2 )
     {  
         SetLastError(ERROR_INVALID_PARAMETER);
@@ -1195,17 +615,7 @@ User32DefWindowProc(HWND hWnd,
         {
             return (DefWndNCLButtonDblClk(hWnd, wParam, lParam));
         }
-/* Moved to Win32k
-        case WM_WINDOWPOSCHANGING:
-        {
-            return (DefWndHandleWindowPosChanging(hWnd, (WINDOWPOS*)lParam));
-        }
 
-        case WM_WINDOWPOSCHANGED:
-        {
-            return (DefWndHandleWindowPosChanged(hWnd, (WINDOWPOS*)lParam));
-        }
-*/
         case WM_NCRBUTTONDOWN:
             return NC_HandleNCRButtonDown( hWnd, wParam, lParam );
 
@@ -1344,34 +754,7 @@ User32DefWindowProc(HWND hWnd,
             }
             return (0);
         }
-/* Moved to Win32k
-        case WM_SYNCPAINT:
-        {
-            HRGN hRgn;
-            hRgn = CreateRectRgn(0, 0, 0, 0);
-            if (GetUpdateRgn(hWnd, hRgn, FALSE) != NULLREGION)
-            {
-                RedrawWindow(hWnd, NULL, hRgn,
-                               RDW_ERASENOW | RDW_ERASE | RDW_FRAME |
-                    RDW_ALLCHILDREN);
-            }
-            DeleteObject(hRgn);
-            return (0);
-        }
 
-        case WM_SETREDRAW:
-        {
-            LONG_PTR Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
-            if (wParam) SetWindowLongPtr(hWnd, GWL_STYLE, Style | WS_VISIBLE);
-            else
-            {
-                RedrawWindow(hWnd, NULL, 0, RDW_ALLCHILDREN | RDW_VALIDATE);
-                Style &= ~WS_VISIBLE;
-                SetWindowLongPtr(hWnd, GWL_STYLE, Style);
-            }
-            return (0);
-        }
-*/
         case WM_CLOSE:
             DestroyWindow(hWnd);
             return (0);
@@ -1885,6 +1268,7 @@ User32DefWindowProc(HWND hWnd,
         case WM_SETHOTKEY:
         case WM_WINDOWPOSCHANGING:
         case WM_WINDOWPOSCHANGED:
+        case WM_APPCOMMAND:
         {
             LRESULT lResult;
             NtUserMessageCall( hWnd, Msg, wParam, lParam, (ULONG_PTR)&lResult, FNID_DEFWINDOWPROC, !bUnicode);