[2/3] user32: Don't show empty popup menus.
Vincent Povirk
madewokherd at gmail.com
Mon Feb 17 16:20:24 CST 2014
-------------- next part --------------
From 0d6b30f9c0e45625ce78386fe9deec109db728e5 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Mon, 17 Feb 2014 15:56:14 -0600
Subject: [PATCH 2/3] user32: Don't show empty popup menus.
---
dlls/user32/menu.c | 11 +++++++++--
dlls/user32/tests/menu.c | 16 ++++++++--------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index bbaa5f3..3852666 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -1849,6 +1849,13 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
}
menu->hwndOwner = hwndOwner;
+ if ((flags & TPM_POPUPMENU) == TPM_POPUPMENU && menu->nItems == 0)
+ {
+ SetLastError( 0 );
+ menu->hWnd = NULL;
+ return FALSE;
+ }
+
menu->nScrollPos = 0;
MENU_PopupMenuCalcSize( menu );
@@ -2386,7 +2393,7 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu,
/* use default alignment for submenus */
wFlags &= ~(TPM_CENTERALIGN | TPM_RIGHTALIGN | TPM_VCENTERALIGN | TPM_BOTTOMALIGN);
- MENU_ShowPopup( hwndOwner, item->hSubMenu, menu->FocusedItem, wFlags,
+ MENU_ShowPopup( hwndOwner, item->hSubMenu, menu->FocusedItem, wFlags & ~TPM_POPUPMENU,
rect.left, rect.top, rect.right, rect.bottom );
if (selectFirst)
MENU_MoveSelection( hwndOwner, item->hSubMenu, ITEM_NEXT );
@@ -3448,7 +3455,7 @@ BOOL WINAPI TrackPopupMenuEx( HMENU hMenu, UINT wFlags, INT x, INT y,
if (!(wFlags & TPM_NONOTIFY))
SendMessageW( hWnd, WM_INITMENUPOPUP, (WPARAM)hMenu, 0);
- if (MENU_ShowPopup( hWnd, hMenu, 0, wFlags, x, y, 0, 0 ))
+ if (MENU_ShowPopup( hWnd, hMenu, 0, wFlags | TPM_POPUPMENU, x, y, 0, 0 ))
ret = MENU_TrackMenu( hMenu, wFlags | TPM_POPUPMENU, 0, 0, hWnd,
lpTpm ? &lpTpm->rcExclude : NULL );
MENU_ExitTracking(hWnd, TRUE);
diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c
index 0be4afc..4f0c3c0 100644
--- a/dlls/user32/tests/menu.c
+++ b/dlls/user32/tests/menu.c
@@ -3252,7 +3252,7 @@ static void test_menu_trackagain(void)
ok(g_hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError());
ret = TrackPopupMenu( g_hmenu, 0, 100, 100, 0, hwnd, NULL);
- todo_wine ok(ret == FALSE, "got %d\n", ret);
+ ok(ret == FALSE, "got %d\n", ret);
DestroyMenu(g_hmenu);
DestroyWindow(hwnd);
@@ -3584,10 +3584,10 @@ static void test_emptypopup(void)
ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
- todo_wine ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
+ ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
- todo_wine ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
- todo_wine ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
+ ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
+ ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = gflag_enteridle = 0;
selectitem_wp = 0xdeadbeef;
@@ -3595,16 +3595,16 @@ static void test_emptypopup(void)
ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL);
err = GetLastError();
- todo_wine ok(ret == 0, "got %i\n", ret);
+ ok(ret == 0, "got %i\n", ret);
ok(err == 0, "got %i\n", err);
ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup);
ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop);
ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu);
- todo_wine ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
+ ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu);
- todo_wine ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
- todo_wine ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
+ ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp);
+ ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp);
SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_fill_in_init);
--
1.8.3.2
More information about the wine-patches
mailing list