Check only for -1 and -2 as special values returned by MENU_ExecFocusedItem

Dmitry Timoshkov dmitry at codeweavers.com
Thu Nov 2 05:19:39 CST 2006


Hello,

an app I'm working on uses negative menu item ids, and clicking on an menu
item doesn't lead to an item "execution". The reason for it is that values
-1 and -2 are used by MENU_ExecFocusedItem as special indicators for actions
it does, but some callers just treat any returned negative value as a failure.
Probably special usage of -2 should be also eliminated.

This patch makes menus in my application work.

Changelog:
    Check only for -1 and -2 as special values returned by MENU_ExecFocusedItem,
    allow any other negative value to be a valid menu item id.

--- cvs/hq/wine/dlls/user/menu.c	2006-10-27 16:20:25.000000000 +0900
+++ wine/dlls/user/menu.c	2006-11-02 19:04:48.000000000 +0800
@@ -2444,7 +2444,7 @@ static INT MENU_ExecFocusedItem( MTRACKE
 
     item = &menu->items[menu->FocusedItem];
 
-    TRACE("%p %08x %p\n", hMenu, item->wID, item->hSubMenu);
+    TRACE("hMenu %p wID %08x hSubMenu %p fType %04x\n", hMenu, item->wID, item->hSubMenu, item->fType);
 
     if (!(item->fType & MF_POPUP))
     {
@@ -2566,10 +2566,13 @@ static INT MENU_ButtonUp( MTRACKER* pmt,
 
 	if( item && (ptmenu->FocusedItem == id ))
 	{
+            debug_print_menuitem ("FocusedItem: ", item, "");
+
 	    if( !(item->fType & MF_POPUP) )
 	    {
 	        INT executedMenuId = MENU_ExecFocusedItem( pmt, hPtMenu, wFlags);
-	        return (executedMenuId < 0) ? -1 : executedMenuId;
+                if (executedMenuId == -1 || executedMenuId == -2) return -1;
+                return executedMenuId;
 	    }
 
 	    /* If we are dealing with the top-level menu            */
@@ -3050,6 +3053,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu,
 		    if (hmenu)
 		    {
                         executedMenuId = MENU_ButtonUp( &mt, hmenu, wFlags);
+                        TRACE("executedMenuId %d\n", executedMenuId);
 
 			/* End the loop if executedMenuId is an item ID */
 			/* or if the job was done (executedMenuId = 0). */
@@ -3214,7 +3218,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu,
 
     /* The return value is only used by TrackPopupMenu */
     if (!(wFlags & TPM_RETURNCMD)) return TRUE;
-    if (executedMenuId < 0) executedMenuId = 0;
+    if (executedMenuId == -1) executedMenuId = 0;
     return executedMenuId;
 }
 
@@ -3364,6 +3368,9 @@ BOOL WINAPI TrackPopupMenu( HMENU hMenu,
 {
     BOOL ret = FALSE;
 
+    TRACE("hmenu %p flags %04x (%d,%d) reserved %d hwnd %p rect %s\n",
+           hMenu, wFlags, x, y, nReserved, hWnd, wine_dbgstr_rect(lpRect));
+
     MENU_InitTracking(hWnd, hMenu, TRUE, wFlags);
 
     /* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */





More information about the wine-patches mailing list