Commit c2734074 authored by Alexandre Julliard's avatar Alexandre Julliard

Fixed TrackPopupMenu return value (based on a patch by Andreas

Rosenberg).
parent 1d5e6b67
...@@ -2639,8 +2639,8 @@ static void MENU_KeyRight( MTRACKER* pmt, UINT wFlags ) ...@@ -2639,8 +2639,8 @@ static void MENU_KeyRight( MTRACKER* pmt, UINT wFlags )
* *
* Menu tracking code. * Menu tracking code.
*/ */
static INT MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y, static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y,
HWND hwnd, const RECT *lprect ) HWND hwnd, const RECT *lprect )
{ {
MSG msg; MSG msg;
POPUPMENU *menu; POPUPMENU *menu;
...@@ -2661,7 +2661,11 @@ static INT MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y, ...@@ -2661,7 +2661,11 @@ static INT MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y,
(lprect) ? lprect->right : 0, (lprect) ? lprect->bottom : 0); (lprect) ? lprect->right : 0, (lprect) ? lprect->bottom : 0);
fEndMenu = FALSE; fEndMenu = FALSE;
if (!(menu = MENU_GetMenu( hmenu ))) return FALSE; if (!(menu = MENU_GetMenu( hmenu )))
{
SetLastError(ERROR_INVALID_MENU_HANDLE);
return FALSE;
}
if (wFlags & TPM_BUTTONDOWN) if (wFlags & TPM_BUTTONDOWN)
{ {
...@@ -2926,7 +2930,9 @@ static INT MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y, ...@@ -2926,7 +2930,9 @@ static INT MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y,
} }
/* The return value is only used by TrackPopupMenu */ /* The return value is only used by TrackPopupMenu */
return ((executedMenuId != -1) ? executedMenuId : 0); if (!(wFlags & TPM_RETURNCMD)) return TRUE;
if (executedMenuId == -1) executedMenuId = 0;
return executedMenuId;
} }
/*********************************************************************** /***********************************************************************
...@@ -3073,12 +3079,9 @@ BOOL WINAPI TrackPopupMenu( HMENU hMenu, UINT wFlags, INT x, INT y, ...@@ -3073,12 +3079,9 @@ BOOL WINAPI TrackPopupMenu( HMENU hMenu, UINT wFlags, INT x, INT y,
SendMessageW( hWnd, WM_INITMENUPOPUP, (WPARAM)hMenu, 0); SendMessageW( hWnd, WM_INITMENUPOPUP, (WPARAM)hMenu, 0);
if (MENU_ShowPopup( hWnd, hMenu, 0, x, y, 0, 0 )) if (MENU_ShowPopup( hWnd, hMenu, 0, x, y, 0, 0 ))
ret = MENU_TrackMenu( hMenu, wFlags | TPM_POPUPMENU, 0, 0, hWnd, lpRect ); ret = MENU_TrackMenu( hMenu, wFlags | TPM_POPUPMENU, 0, 0, hWnd, lpRect );
MENU_ExitTracking(hWnd); MENU_ExitTracking(hWnd);
if( (!(wFlags & TPM_RETURNCMD)) && (ret != FALSE) )
ret = 1;
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment