Module: wine Branch: master Commit: 55ff0661038da271d92b5951a62f66e898b8cba2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=55ff0661038da271d92b5951a6...
Author: Piotr Caban piotr@codeweavers.com Date: Thu Apr 10 14:50:33 2014 +0200
user32: Don't fail on windows without menu bar in DrawMenuBar.
---
dlls/user32/menu.c | 17 +++++++++-------- dlls/user32/tests/menu.c | 2 -- dlls/user32/tests/msg.c | 11 +++++++++-- 3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index 8bb508d..4a49ce6 100644 --- a/dlls/user32/menu.c +++ b/dlls/user32/menu.c @@ -4360,17 +4360,18 @@ HMENU WINAPI GetSubMenu( HMENU hMenu, INT nPos ) BOOL WINAPI DrawMenuBar( HWND hWnd ) { LPPOPUPMENU lppop; - HMENU hMenu = GetMenu(hWnd); + HMENU hMenu;
- if (!WIN_ALLOWED_MENU(GetWindowLongW( hWnd, GWL_STYLE ))) + if (!IsWindow( hWnd )) return FALSE; - if (!hMenu || !(lppop = MENU_GetMenu( hMenu ))) return FALSE;
- lppop->Height = 0; /* Make sure we call MENU_MenuBarCalcSize */ - lppop->hwndOwner = hWnd; - SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | - SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); - return TRUE; + if ((hMenu = GetMenu( hWnd )) && (lppop = MENU_GetMenu( hMenu ))) { + lppop->Height = 0; /* Make sure we call MENU_MenuBarCalcSize */ + lppop->hwndOwner = hWnd; + } + + return SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | + SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); }
/*********************************************************************** diff --git a/dlls/user32/tests/menu.c b/dlls/user32/tests/menu.c index 7cab0a0..5fbe317 100644 --- a/dlls/user32/tests/menu.c +++ b/dlls/user32/tests/menu.c @@ -425,9 +425,7 @@ static void test_menu_locked_by_window(void) ok(ret, "DestroyMenu failed with error %d\n", GetLastError());
ret = DrawMenuBar(hwnd); - todo_wine { ok(ret, "DrawMenuBar failed with error %d\n", GetLastError()); - } ret = IsMenu(GetMenu(hwnd)); ok(!ret || broken(ret) /* nt4 */, "Menu handle should have been destroyed\n");
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 7053ead..a209492 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -4819,13 +4819,19 @@ static void test_messages(void) after_end_dialog = FALSE; test_def_id = FALSE;
- hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP, + hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP|WS_CHILD, 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL); ok(hwnd != 0, "Failed to create custom dialog window\n"); flush_sequence(); trace("call ShowWindow(%p, SW_SHOW)\n", hwnd); ShowWindow(hwnd, SW_SHOW); ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE); + + flush_events(); + flush_sequence(); + ok(DrawMenuBar(hwnd), "DrawMenuBar failed: %d\n", GetLastError()); + flush_events(); + ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE); DestroyWindow(hwnd);
flush_sequence(); @@ -4836,7 +4842,8 @@ static void test_messages(void) flush_sequence();
/* Message sequence for SetMenu */ - ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n"); + ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a destroyed window\n"); + ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "last error is %d\n", GetLastError()); ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
hmenu = CreateMenu();