From 115bbf424cc0f5ea325e3052aed8ad8106045294 Mon Sep 17 00:00:00 2001 From: Fabian Maurer Date: Thu, 2 Feb 2017 16:33:54 +0100 Subject: [PATCH] user32: Don't send WM_CHAR when a menu gets VK_ESCAPE and add tests. Signed-off-by: Fabian Maurer Signed-off-by: Alexandre Julliard --- dlls/user32/menu.c | 2 +- dlls/user32/tests/msg.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index 59fcd9c488e..827bee734e3 100644 --- a/dlls/user32/menu.c +++ b/dlls/user32/menu.c @@ -3077,7 +3077,6 @@ static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y, break; } - TranslateMessage( &msg ); mt.pt = msg.pt; if ( (msg.hwnd==menu->hWnd) || (msg.message!=WM_TIMER) ) @@ -3206,6 +3205,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y, } default: + TranslateMessage( &msg ); break; } break; /* WM_KEYDOWN */ diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 45b5222deba..c608c11c223 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -1675,6 +1675,10 @@ static const struct message WmTrackPopupMenu[] = { { 0 } }; +static const struct message WmTrackPopupMenuEsc[] = { + { 0 } +}; + static const struct message WmTrackPopupMenuCapture[] = { { HCBT_CREATEWND, hook }, { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 }, @@ -15637,6 +15641,7 @@ static LRESULT WINAPI cancel_init_proc(HWND hwnd, UINT message, WPARAM wParam, L static void test_TrackPopupMenu(void) { + MSG msg; HWND hwnd; BOOL ret; @@ -15659,6 +15664,20 @@ static void test_TrackPopupMenu(void) ok_sequence(WmTrackPopupMenu, "TrackPopupMenu", TRUE); ok(ret == 1, "TrackPopupMenu failed with error %i\n", GetLastError()); + /* Test popup closing with an ESC-press */ + flush_events(); + PostMessageW(hwnd, WM_KEYDOWN, VK_ESCAPE, 0); + ret = TrackPopupMenu(hpopupmenu, 0, 100,100, 0, hwnd, NULL); + ok(ret == 1, "TrackPopupMenu failed with error %i\n", GetLastError()); + PostQuitMessage(0); + flush_sequence(); + while ( PeekMessageA(&msg, 0, 0, 0, PM_REMOVE) ) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + ok_sequence(WmTrackPopupMenuEsc, "TrackPopupMenuEsc", FALSE); /* Shouldn't get any message */ + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)cancel_init_proc); flush_events();