From: Vincent Povirk Subject: [1/5] user32: Allow EndMenu() calls from WM_ENTERMENULOOP. Message-Id: Date: Wed, 16 Apr 2014 14:05:32 -0500 From 687dcb7138c1be7bed2ed09d1ee9b377f3b9e810 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 16 Apr 2014 12:56:09 -0500 Subject: [PATCH 01/11] user32: Allow EndMenu() calls from WM_ENTERMENULOOP. --- dlls/user32/menu.c | 13 ++++++++++--- dlls/user32/tests/menu.c | 15 +++------------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index 4a49ce6..6b0cf2f 100644 --- a/dlls/user32/menu.c +++ b/dlls/user32/menu.c @@ -3015,7 +3015,6 @@ static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y, TRACE("hmenu=%p flags=0x%08x (%d,%d) hwnd=%p %s\n", hmenu, wFlags, x, y, hwnd, wine_dbgstr_rect( lprect)); - fEndMenu = FALSE; if (!(menu = MENU_GetMenu( hmenu ))) { WARN("Invalid menu handle %p\n", hmenu); @@ -3306,12 +3305,20 @@ static BOOL MENU_InitTracking(HWND hWnd, HMENU hMenu, BOOL bPopup, UINT wFlags) HideCaret(0); + if (!(menu = MENU_GetMenu( hMenu ))) return FALSE; + /* This makes the menus of applications built with Delphi work. * It also enables menus to be displayed in more than one window, * but there are some bugs left that need to be fixed in this case. */ - if (!bPopup && (menu = MENU_GetMenu( hMenu ))) menu->hWnd = hWnd; - if (!top_popup) top_popup_hmenu = hMenu; + if (!bPopup) menu->hWnd = hWnd; + if (!top_popup) + { + top_popup = menu->hWnd; + top_popup_hmenu = hMenu; + } + + fEndMenu = FALSE; /* Send WM_ENTERMENULOOP and WM_INITMENU message only if TPM_NONOTIFY flag is not specified */ if (!(wFlags & TPM_NONOTIFY)) diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c index 5fbe317..dc91c6a 100644 --- a/dlls/user32/tests/menu.c +++ b/dlls/user32/tests/menu.c @@ -3324,17 +3324,11 @@ static void test_menu_cancelmode(void) /* menu owner is top level window */ g_hwndtosend = hwnd; TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); - todo_wine { - ok( g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); - } - ok( g_got_enteridle < 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle); + ok( g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); /* menu owner is child window */ g_hwndtosend = hwndchild; TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL); - todo_wine { - ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); - } - ok(g_got_enteridle < 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle); + ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); /* now send the WM_CANCELMODE messages to the WRONG window */ /* those should fail ( to have any effect) */ g_hwndtosend = hwnd; @@ -3354,10 +3348,7 @@ static void test_menu_cancelmode(void) ok( ret == 0, "Sending WM_SYSCOMMAND/SC_KEYMENU failed lasterror is %u\n", GetLastError()); while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); - todo_wine { - ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); - } - ok(g_got_enteridle < 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle); + ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); /* cleanup */ DestroyMenu( menubar ); -- 1.8.3.2