Commit e64b8753 authored by Ulrich Czekalla's avatar Ulrich Czekalla Committed by Alexandre Julliard

Child windows with the WS_POPUP style are allowed to have a menu.

parent 6f9ddc3b
...@@ -161,6 +161,8 @@ typedef struct ...@@ -161,6 +161,8 @@ typedef struct
MF_POPUP | MF_SYSMENU | MF_HELP) MF_POPUP | MF_SYSMENU | MF_HELP)
#define STATE_MASK (~TYPE_MASK) #define STATE_MASK (~TYPE_MASK)
#define WIN_ALLOWED_MENU(style) ((style & (WS_CHILD | WS_POPUP)) != WS_CHILD)
/* Dimension of the menu bitmaps */ /* Dimension of the menu bitmaps */
static WORD arrow_bitmap_width = 0, arrow_bitmap_height = 0; static WORD arrow_bitmap_width = 0, arrow_bitmap_height = 0;
...@@ -2988,8 +2990,8 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar) ...@@ -2988,8 +2990,8 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar)
/* find window that has a menu */ /* find window that has a menu */
while (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD) while (!WIN_ALLOWED_MENU(GetWindowLongW( hwnd, GWL_STYLE )))
if (!(hwnd = GetParent( hwnd ))) return; if (!(hwnd = GetAncestor( hwnd, GA_PARENT ))) return;
/* check if we have to track a system menu */ /* check if we have to track a system menu */
...@@ -3758,7 +3760,8 @@ BOOL MENU_SetMenu( HWND hWnd, HMENU hMenu ) ...@@ -3758,7 +3760,8 @@ BOOL MENU_SetMenu( HWND hWnd, HMENU hMenu )
WARN("hMenu %p is not a menu handle\n", hMenu); WARN("hMenu %p is not a menu handle\n", hMenu);
return FALSE; return FALSE;
} }
if (GetWindowLongW( hWnd, GWL_STYLE ) & WS_CHILD) return FALSE; if (!WIN_ALLOWED_MENU(GetWindowLongW( hWnd, GWL_STYLE )))
return FALSE;
hWnd = WIN_GetFullHandle( hWnd ); hWnd = WIN_GetFullHandle( hWnd );
if (GetCapture() == hWnd) MENU_SetCapture(0); /* release the capture */ if (GetCapture() == hWnd) MENU_SetCapture(0); /* release the capture */
...@@ -3812,7 +3815,8 @@ BOOL WINAPI DrawMenuBar( HWND hWnd ) ...@@ -3812,7 +3815,8 @@ BOOL WINAPI DrawMenuBar( HWND hWnd )
LPPOPUPMENU lppop; LPPOPUPMENU lppop;
HMENU hMenu = GetMenu(hWnd); HMENU hMenu = GetMenu(hWnd);
if (GetWindowLongW( hWnd, GWL_STYLE ) & WS_CHILD) return FALSE; if (!WIN_ALLOWED_MENU(GetWindowLongW( hWnd, GWL_STYLE )))
return FALSE;
if (!hMenu || !(lppop = MENU_GetMenu( hMenu ))) return FALSE; if (!hMenu || !(lppop = MENU_GetMenu( hMenu ))) return FALSE;
lppop->Height = 0; /* Make sure we call MENU_MenuBarCalcSize */ lppop->Height = 0; /* Make sure we call MENU_MenuBarCalcSize */
......
...@@ -1749,6 +1749,7 @@ static void test_SetMenu(HWND parent) ...@@ -1749,6 +1749,7 @@ static void test_SetMenu(HWND parent)
HMENU hMenu, ret; HMENU hMenu, ret;
BOOL is_win9x = GetWindowLongPtrW(parent, GWLP_WNDPROC) == 0; BOOL is_win9x = GetWindowLongPtrW(parent, GWLP_WNDPROC) == 0;
BOOL retok; BOOL retok;
DWORD style;
hMenu = CreateMenu(); hMenu = CreateMenu();
assert(hMenu); assert(hMenu);
...@@ -1812,6 +1813,16 @@ static void test_SetMenu(HWND parent) ...@@ -1812,6 +1813,16 @@ static void test_SetMenu(HWND parent)
ret = GetMenu(child); ret = GetMenu(child);
ok(ret == (HMENU)10, "unexpected menu id %p\n", ret); ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
style = GetWindowLong(child, GWL_STYLE);
SetWindowLong(child, GWL_STYLE, style | WS_POPUP);
ok(SetMenu(child, hMenu), "SetMenu on a popup child window should not fail\n");
ok(SetMenu(child, 0), "SetMenu on a popup child window should not fail\n");
SetWindowLong(child, GWL_STYLE, style);
SetWindowLong(child, GWL_STYLE, style | WS_OVERLAPPED);
ok(!SetMenu(child, hMenu), "SetMenu on a overlapped child window should fail\n");
SetWindowLong(child, GWL_STYLE, style);
DestroyWindow(child); DestroyWindow(child);
DestroyMenu(hMenu); DestroyMenu(hMenu);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment