user32: Don't send WM_CHAR when a menu gets VK_ESCAPE and add tests.

Signed-off-by: Fabian Maurer <dark.shadow4@web.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Fabian Maurer 2017-02-02 16:33:54 +01:00 committed by Alexandre Julliard
parent 182fad8b3a
commit 115bbf424c
2 changed files with 20 additions and 1 deletions

View File

@ -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 */

View File

@ -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();