WM_NCHITTEST - Check In Client Area First

Robert Shearman rob at codeweavers.com
Fri Sep 24 10:39:57 CDT 2004


Changelog:
Check in client area before caption area, because the app may have 
changed the NC area in WM_NCCALCSIZE.
-------------- next part --------------
diff -u -N -r -x '*~' -x '.#*' -x CVS -x Makefile -x '*.o' -x '*.orig' -x '*.diff' -x '*.rej' -x '*.spec.c' wine/windows_old/nonclient.c wine/windows/nonclient.c
--- wine/windows_old/nonclient.c	2004-09-24 16:32:24.192305928 +0100
+++ wine/windows/nonclient.c	2004-09-24 16:32:37.082346344 +0100
@@ -478,7 +478,8 @@
 
 static LONG NC_DoNCHitTest (WND *wndPtr, POINT pt )
 {
-    RECT rect;
+    RECT rect, rcClient;
+    POINT ptClient;
 
     TRACE("hwnd=%p pt=%ld,%ld\n", wndPtr->hwndSelf, pt.x, pt.y );
 
@@ -487,6 +488,12 @@
 
     if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION;
 
+    /* Check client area */
+    ptClient = pt;
+    ScreenToClient( wndPtr->hwndSelf, &ptClient );
+    GetClientRect( wndPtr->hwndSelf, &rcClient );
+    if (PtInRect( &rcClient, ptClient )) return HTCLIENT;
+
     /* Check borders */
     if (HAS_THICKFRAME( wndPtr->dwStyle, wndPtr->dwExStyle ))
     {
@@ -573,45 +580,39 @@
         }
     }
 
-      /* Check client area */
-
-    ScreenToClient( wndPtr->hwndSelf, &pt );
-    GetClientRect( wndPtr->hwndSelf, &rect );
-    if (PtInRect( &rect, pt )) return HTCLIENT;
-
       /* Check vertical scroll bar */
 
     if (wndPtr->dwStyle & WS_VSCROLL)
     {
         if((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0)
-            rect.left -= GetSystemMetrics(SM_CXVSCROLL);
+            rcClient.left -= GetSystemMetrics(SM_CXVSCROLL);
         else
-            rect.right += GetSystemMetrics(SM_CXVSCROLL);
-        if (PtInRect( &rect, pt )) return HTVSCROLL;
+            rcClient.right += GetSystemMetrics(SM_CXVSCROLL);
+        if (PtInRect( &rcClient, ptClient )) return HTVSCROLL;
     }
 
       /* Check horizontal scroll bar */
 
     if (wndPtr->dwStyle & WS_HSCROLL)
     {
-	rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
-	if (PtInRect( &rect, pt ))
-	{
-	      /* Check size box */
-	    if ((wndPtr->dwStyle & WS_VSCROLL) &&
-		((((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) && (pt.x <= rect.left + GetSystemMetrics(SM_CXVSCROLL))) ||
-		(((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) == 0) && (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))))
-		return HTSIZE;
-	    return HTHSCROLL;
-	}
+        rcClient.bottom += GetSystemMetrics(SM_CYHSCROLL);
+        if (PtInRect( &rcClient, ptClient ))
+        {
+            /* Check size box */
+            if ((wndPtr->dwStyle & WS_VSCROLL) &&
+                ((((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) != 0) && (ptClient.x <= rcClient.left + GetSystemMetrics(SM_CXVSCROLL))) ||
+                (((wndPtr->dwExStyle & WS_EX_LEFTSCROLLBAR) == 0) && (ptClient.x >= rcClient.right - GetSystemMetrics(SM_CXVSCROLL)))))
+                return HTSIZE;
+            return HTHSCROLL;
+        }
     }
 
       /* Check menu bar */
 
     if (HAS_MENU(wndPtr))
     {
-	if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
-	    return HTMENU;
+        if ((ptClient.y < 0) && (ptClient.x >= 0) && (ptClient.x < rcClient.right))
+            return HTMENU;
     }
 
     /* Has to return HTNOWHERE if nothing was found


More information about the wine-patches mailing list