[NtUser]
[reactos.git] / reactos / win32ss / user / ntuser / nonclient.c
index 0f1b5cf..3ce9cff 100644 (file)
@@ -214,6 +214,7 @@ DefWndStartSizeMove(PWND Wnd, WPARAM wParam, POINT *capturePoint)
                case VK_ESCAPE:
                  return 0;
                }
+              break;
             default:
               IntTranslateKbdMessage( &msg, 0 );
               pti->TIF_flags |= TIF_MOVESIZETRACKING;
@@ -612,11 +613,6 @@ PCURICON_OBJECT FASTCALL NC_IconForWindow( PWND pWnd )
     PCURICON_OBJECT pIcon = NULL;
     HICON hIcon;
 
-   //FIXME: Some callers use this function as if it returns a boolean saying "this window has an icon".
-   //FIXME: Hence we must return a pointer with no reference count.
-   //FIXME: This is bad and we should feel bad.
-   //FIXME: Stop whining over wine code.
-
    hIcon = UserGetProp(pWnd, gpsi->atomIconSmProp, TRUE);
    if (!hIcon) hIcon = UserGetProp(pWnd, gpsi->atomIconProp, TRUE);
 
@@ -635,11 +631,9 @@ PCURICON_OBJECT FASTCALL NC_IconForWindow( PWND pWnd )
    }
    if (hIcon)
    {
-       pIcon = UserGetCurIconObject(hIcon);
-       if (pIcon)
-       {
-           UserDereferenceObject(pIcon);
-       }
+       pIcon = (PCURICON_OBJECT)UserGetObjectNoErr(gHandleTable,
+                                                   hIcon,
+                                                   TYPE_CURSOR);
    }
    return pIcon;
 }
@@ -679,17 +673,11 @@ IntIsScrollBarVisible(PWND pWnd, INT hBar)
   return !(sbi.rgstate[0] & STATE_SYSTEM_OFFSCREEN);
 }
 
-BOOL
-UserHasMenu(PWND pWnd, ULONG Style)
-{
-   return (!(Style & WS_CHILD) && UlongToHandle(pWnd->IDMenu) != 0);
-}
-
 /*
  * FIXME:
  * - Cache bitmaps, then just bitblt instead of calling DFC() (and
  *   wasting precious CPU cycles) every time
- * - Center the buttons verticaly in the rect
+ * - Center the buttons vertically in the rect
  */
 VOID
 UserDrawCaptionButton(PWND pWnd, LPRECT Rect, DWORD Style, DWORD ExStyle, HDC hDC, BOOL bDown, ULONG Type)
@@ -751,8 +739,7 @@ UserDrawCaptionButton(PWND pWnd, LPRECT Rect, DWORD Style, DWORD ExStyle, HDC hD
           PMENU pSysMenu = IntGetSystemMenu(pWnd, FALSE);
           UINT MenuState = IntGetMenuState(UserHMGetHandle(pSysMenu), SC_CLOSE, MF_BYCOMMAND); /* in case of error MenuState==0xFFFFFFFF */
 
-         /* FIXME: A tool window has a smaller Close button */
-
+         /* A tool window has a smaller Close button */
          if (ExStyle & WS_EX_TOOLWINDOW)
          {
             TempRect.left = TempRect.right - UserGetSystemMetrics(SM_CXSMSIZE);
@@ -853,7 +840,7 @@ VOID UserDrawCaptionBar(
 
    if (!(Flags & DC_NOVISIBLE) && !IntIsWindowVisible(pWnd)) return;
 
-   ERR("UserDrawCaptionBar: pWnd %p, hDc %p, Flags 0x%x.\n", pWnd, hDC, Flags);
+   TRACE("UserDrawCaptionBar: pWnd %p, hDc %p, Flags 0x%x.\n", pWnd, hDC, Flags);
 
    Style = pWnd->style;
    ExStyle = pWnd->ExStyle;
@@ -950,12 +937,12 @@ VOID UserDrawCaptionBar(
 
    if (!(Style & WS_MINIMIZE))
    {
-      PMENU menu = UserGetMenuObject(UlongToHandle(pWnd->IDMenu));
       /* Draw menu bar */
-      if (menu && !(Style & WS_CHILD))
+      if (pWnd->state & WNDS_HASMENU && pWnd->IDMenu) // Should be pWnd->spmenu
       {
+          PMENU menu = UserGetMenuObject(UlongToHandle(pWnd->IDMenu)); // FIXME!
           TempRect = CurrentRect;
-          TempRect.bottom = TempRect.top + menu->cyMenu;
+          TempRect.bottom = TempRect.top + menu->cyMenu; // Should be pWnd->spmenu->cyMenu;
           CurrentRect.top += MENU_DrawMenuBar(hDC, &TempRect, pWnd, FALSE);
       }
 
@@ -1119,13 +1106,16 @@ NC_DoNCPaint(PWND pWnd, HDC hDC, INT Flags)
 
    if (!(Style & WS_MINIMIZE))
    {
-     PMENU menu = UserGetMenuObject(UlongToHandle(pWnd->IDMenu));
      /* Draw menu bar */
-     if (menu && !(Style & WS_CHILD))
+     if (pWnd->state & WNDS_HASMENU && pWnd->IDMenu) // Should be pWnd->spmenu
      {
-         TempRect = CurrentRect;
-         TempRect.bottom = TempRect.top + menu->cyMenu;
-         if (!(Flags & DC_NOSENDMSG)) CurrentRect.top += MENU_DrawMenuBar(hDC, &TempRect, pWnd, FALSE);
+         if (!(Flags & DC_NOSENDMSG))
+         {
+             PMENU menu = UserGetMenuObject(UlongToHandle(pWnd->IDMenu)); // FIXME!
+             TempRect = CurrentRect;
+             TempRect.bottom = TempRect.top + menu->cyMenu; // Should be pWnd->spmenu->cyMenu;
+             CurrentRect.top += MENU_DrawMenuBar(hDC, &TempRect, pWnd, FALSE);
+         }
      }
 
      if (ExStyle & WS_EX_CLIENTEDGE)
@@ -1226,7 +1216,7 @@ LRESULT NC_HandleNCCalcSize( PWND Wnd, WPARAM wparam, RECTL *Rect, BOOL Suspende
             Rect->top += UserGetSystemMetrics(SM_CYCAPTION);
       }
 
-      if (Wnd->IDMenu && ((Wnd->style & (WS_CHILD | WS_POPUP)) != WS_CHILD))
+      if (HAS_MENU(Wnd, Style))
       {
          HDC hDC = UserGetDCEx(Wnd, 0, DCX_USESTYLE | DCX_WINDOW);
 
@@ -1382,7 +1372,7 @@ LRESULT NC_HandleNCActivate( PWND Wnd, WPARAM wParam, LPARAM lParam )
    }
 
    if ((Wnd->state & WNDS_NONCPAINT) || !(Wnd->style & WS_VISIBLE))
-      return 0;
+      return TRUE;
 
    /* This isn't documented but is reproducible in at least XP SP2 and
     * Outlook 2007 depends on it
@@ -1960,6 +1950,8 @@ GetNCHitEx(PWND pWnd, POINT pt)
             RECTL_vInflateRect(&rcWindow, -UserGetSystemMetrics(SM_CXDLGFRAME), -UserGetSystemMetrics(SM_CYDLGFRAME));
         else if (HAS_THINFRAME( Style, ExStyle ))
             RECTL_vInflateRect(&rcWindow, -UserGetSystemMetrics(SM_CXBORDER), -UserGetSystemMetrics(SM_CYBORDER));
+        else if (HAS_CLIENTFRAME( Style, ExStyle ))
+            RECTL_vInflateRect(&rcWindow, -UserGetSystemMetrics(SM_CXEDGE), -UserGetSystemMetrics(SM_CYEDGE));
         if (!RECTL_bPointInRect( &rcWindow, pt.x, pt.y  )) return HTBORDER;
     }