user: Fix GetMenuItemRect() for top-level menus

tkho at ucla.edu tkho at ucla.edu
Wed Apr 26 19:45:31 CDT 2006


Hello,

This is patch #3 of 3 of menu bug fixes. This patch fixes the behavior of
GetMenuItemRect() for top-level menus. GetMenuItemRect() was previously using
window-relative positions for top-level menus instead of client-area relative
positions.

Thanks,

Thomas Kho

2006-04-26 Thomas Kho <tkho at ucla.edu>

	* dlls/user/tests/menu.c:
	user: Fix GetMenuItemRect() for top-level menus

 menu.c       |   16 ++++++++++++++--
 tests/menu.c |   12 ++++++------
 2 files changed, 20 insertions(+), 8 deletions(-)

Signed-off-by: Thomas Kho <tkho at ucla.edu>
diff -aur ../3/dlls/user/menu.c ./dlls/user/menu.c
--- ../3/dlls/user/menu.c	2006-04-26 17:16:48.000000000 -0700
+++ ./dlls/user/menu.c	2006-04-26 17:17:06.000000000 -0700
@@ -4829,9 +4829,9 @@
      item = MENU_FindItem (&hMenu, &uItem, MF_BYPOSITION);
      referenceHwnd = hwnd;
 
+     itemMenu = MENU_GetMenu(hMenu);
      if(!hwnd)
      {
-	 itemMenu = MENU_GetMenu(hMenu);
 	 if (itemMenu == NULL)
 	     return FALSE;
 
@@ -4845,7 +4845,19 @@
 
      *rect = item->rect;
 
-     MapWindowPoints(referenceHwnd, 0, (LPPOINT)rect, 2);
+     if (itemMenu && !(itemMenu->wFlags & MF_POPUP))
+     {
+         /* Perhaps this special case should be eliminated and the coordinates
+          * should be relative to client area instead of window frame */
+         RECT rectWnd;
+         GetWindowRect(referenceHwnd, &rectWnd);
+         rect->top += rectWnd.top;
+         rect->bottom += rectWnd.top;
+         rect->left += rectWnd.left;
+         rect->right += rectWnd.left;
+     }
+     else
+         MapWindowPoints(referenceHwnd, 0, (LPPOINT)rect, 2);
 
      return TRUE;
 }
diff -aur ../3/dlls/user/tests/menu.c ./dlls/user/tests/menu.c
--- ../3/dlls/user/tests/menu.c	2006-04-26 17:16:49.000000000 -0700
+++ ./dlls/user/tests/menu.c	2006-04-26 17:17:07.000000000 -0700
@@ -1525,16 +1525,16 @@
     { INPUT_KEYBOARD, {{0}}, {VK_LMENU, 'M', 'P', 0}, TRUE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {'E', 0}, FALSE, FALSE },
 
-    { INPUT_MOUSE, {{1, 2}, {0}}, {0}, TRUE, TRUE }, /* test 18 */
+    { INPUT_MOUSE, {{1, 2}, {0}}, {0}, TRUE, FALSE }, /* test 18 */
     { INPUT_MOUSE, {{1, 1}, {0}}, {0}, FALSE, FALSE },
-    { INPUT_MOUSE, {{1, 0}, {0}}, {0}, TRUE, TRUE },
+    { INPUT_MOUSE, {{1, 0}, {0}}, {0}, TRUE, FALSE },
     { INPUT_MOUSE, {{1, 1}, {0}}, {0}, FALSE, FALSE },
-    { INPUT_MOUSE, {{1, 0}, {2, 2}, {0}}, {0}, TRUE, TRUE },
+    { INPUT_MOUSE, {{1, 0}, {2, 2}, {0}}, {0}, TRUE, FALSE },
     { INPUT_MOUSE, {{2, 1}, {0}}, {0}, FALSE, FALSE },
-    { INPUT_MOUSE, {{1, 0}, {2, 0}, {0}}, {0}, TRUE, TRUE },
+    { INPUT_MOUSE, {{1, 0}, {2, 0}, {0}}, {0}, TRUE, FALSE },
     { INPUT_MOUSE, {{3, 0}, {0}}, {0}, FALSE, FALSE },
-    { INPUT_MOUSE, {{1, 0}, {2, 0}, {0}}, {0}, TRUE, TRUE },
-    { INPUT_MOUSE, {{3, 1}, {0}}, {0}, TRUE, TRUE },
+    { INPUT_MOUSE, {{1, 0}, {2, 0}, {0}}, {0}, TRUE, FALSE },
+    { INPUT_MOUSE, {{3, 1}, {0}}, {0}, TRUE, FALSE },
     { INPUT_MOUSE, {{1, 1}, {0}}, {0}, FALSE, FALSE },
     { -1 }
 };



More information about the wine-patches mailing list