I was thinking about fixing the bug 1848.
Here are parts of the involved functions.
See my comments/questions with multiple *** inside: ------------------------------- BOOL WINAPI TrackPopupMenu( HMENU hMenu, UINT wFlags, INT x, INT y, INT nReserved, HWND hWnd, const RECT *lpRect ) { BOOL ret = FALSE;
MENU_InitTracking(hWnd, hMenu, TRUE, wFlags); /****** returns always TRUE */
/* Send WM_INITMENUPOPUP message only if TPM_NONOTIFY flag is not specified */ if (!(wFlags & TPM_NONOTIFY)) SendMessageW( hWnd, WM_INITMENUPOPUP, (WPARAM)hMenu, 0);
if (MENU_ShowPopup( hWnd, hMenu, 0, x, y, 0, 0 )) /****** this may return FALSE if MENU_GetMenu fails */
/****** how can we decide if the call failed, or a click outside the menu happened ???? */ /****** I would suggest to let MENU_TrackMenu return -1 if clicked outside the menu and zero if */ /****** something fails - this requires no other change */ ret = MENU_TrackMenu( hMenu, wFlags | TPM_POPUPMENU, 0, 0, hWnd, lpRect );
MENU_ExitTracking(hWnd); /***** returns always TRUE */
if( (!(wFlags & TPM_RETURNCMD)) && (ret != FALSE) ) /****** FALSE = 0*/ ret = TRUE;
return ret; }
static INT MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y, HWND hwnd, const RECT *lprect ) { ..... INT executedMenuId = -1; .... /*** If I understood things right - simply return executedMenuId */ /*** suggestion: return (executedMenuId) */ /*** could somebody please comment, if my assumption is correct? */ return ((executedMenuId != -1) ? executedMenuId : 0); }