user32: Don't always insert menu items during WM_MDISETMENU.
MSDN says WM_MDISETMENU shouldn't change the frame menu if it is given as NULL. Tests bear that out. Some other tests are included to show we haven't broken behavior on e.g. initially maximized MDI child windows. Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c98ec64a9e
commit
c1c3198aa4
|
@ -370,17 +370,6 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame,
|
|||
return (LRESULT)oldFrameMenu;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* SetMenu() may already have been called, meaning that this window
|
||||
* already has its menu. But they may have done a SetMenu() on
|
||||
* an MDI window, and called MDISetMenu() after the fact, meaning
|
||||
* that the "if" to this "else" wouldn't catch the need to
|
||||
* augment the frame menu.
|
||||
*/
|
||||
if( ci->hwndChildMaximized )
|
||||
MDI_AugmentFrameMenu( hwndFrame, ci->hwndChildMaximized );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1381,6 +1381,9 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
static const WCHAR classW[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
|
||||
static const WCHAR titleW[] = {'M','D','I',' ','c','h','i','l','d',0};
|
||||
BOOL isWin9x = FALSE;
|
||||
HMENU frame_menu = GetMenu(parent);
|
||||
|
||||
ok(frame_menu != NULL, "Frame window didn't have a menu\n");
|
||||
|
||||
mdi_cs.szClass = "MDI_child_Class_1";
|
||||
mdi_cs.szTitle = "MDI child";
|
||||
|
@ -1424,6 +1427,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
ok(id == first_id, "wrong child id %ld\n", id);
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
}
|
||||
|
@ -1449,6 +1453,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
|
||||
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
}
|
||||
|
@ -1465,6 +1470,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
|
||||
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
|
||||
|
@ -1479,6 +1485,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
ok(id == first_id, "wrong child id %ld\n", id);
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
|
||||
|
@ -1499,6 +1506,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
ok(id == first_id, "wrong child id %ld\n", id);
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
}
|
||||
|
@ -1525,6 +1533,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
|
||||
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
}
|
||||
|
@ -1541,6 +1550,26 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
|
||||
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
|
||||
mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
|
||||
WS_MAXIMIZE,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
mdi_client, 0, GetModuleHandleA(NULL),
|
||||
mdi_lParam_test_message);
|
||||
ok(mdi_child != 0, "MDI child creation failed\n");
|
||||
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
||||
ok(id == first_id, "wrong child id %ld\n", id);
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
|
||||
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
|
||||
if (GetWindowLongA(mdi_client, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
else
|
||||
ok(GetMenuItemCount(frame_menu) == 4, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
|
||||
|
@ -1555,6 +1584,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
ok(id == first_id, "wrong child id %ld\n", id);
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
|
||||
|
@ -1575,6 +1605,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
ok(id == first_id, "wrong child id %ld\n", id);
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
}
|
||||
|
@ -1601,6 +1632,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
|
||||
ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
||||
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
||||
}
|
||||
|
@ -1626,6 +1658,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
ok(mdi_child != 0, "MDI child creation failed\n");
|
||||
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
||||
ok(id == 0, "wrong child id %ld\n", id);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
|
||||
DestroyWindow(mdi_child);
|
||||
|
@ -1641,6 +1674,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
ok(id == 0, "wrong child id %ld\n", id);
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
DestroyWindow(mdi_child);
|
||||
|
||||
/* maximized child */
|
||||
|
@ -1655,6 +1689,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
ok(id == 0, "wrong child id %ld\n", id);
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
DestroyWindow(mdi_child);
|
||||
|
||||
trace("Creating maximized child with a caption\n");
|
||||
|
@ -1669,6 +1704,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
ok(id == 0, "wrong child id %ld\n", id);
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
DestroyWindow(mdi_child);
|
||||
|
||||
trace("Creating maximized child with a caption and a thick frame\n");
|
||||
|
@ -1683,6 +1719,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
|||
ok(id == 0, "wrong child id %ld\n", id);
|
||||
hwnd = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
|
||||
ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
|
||||
DestroyWindow(mdi_child);
|
||||
}
|
||||
|
||||
|
@ -1796,7 +1833,7 @@ static LRESULT WINAPI mdi_child_wnd_proc_1(HWND hwnd, UINT msg, WPARAM wparam, L
|
|||
ok(cs->hInstance == mdi_cs->hOwner, "%p != %p\n", cs->hInstance, mdi_cs->hOwner);
|
||||
|
||||
/* MDICREATESTRUCT should have original values */
|
||||
ok(mdi_cs->style == 0 || mdi_cs->style == 0x7fffffff || mdi_cs->style == 0xffffffff,
|
||||
ok(mdi_cs->style == 0 || mdi_cs->style == 0x7fffffff || mdi_cs->style == 0xffffffff || mdi_cs->style == WS_MAXIMIZE,
|
||||
"mdi_cs->style does not match (%08x)\n", mdi_cs->style);
|
||||
ok(mdi_cs->x == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->x);
|
||||
ok(mdi_cs->y == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->y);
|
||||
|
@ -2073,11 +2110,12 @@ static BOOL mdi_RegisterWindowClasses(void)
|
|||
static void test_mdi(void)
|
||||
{
|
||||
static const DWORD style[] = { 0, WS_HSCROLL, WS_VSCROLL, WS_HSCROLL | WS_VSCROLL };
|
||||
HWND mdi_hwndMain, mdi_client;
|
||||
HWND mdi_hwndMain, mdi_client, mdi_child;
|
||||
CLIENTCREATESTRUCT client_cs;
|
||||
RECT rc;
|
||||
DWORD i;
|
||||
MSG msg;
|
||||
HMENU frame_menu, child_menu;
|
||||
|
||||
if (!mdi_RegisterWindowClasses()) assert(0);
|
||||
|
||||
|
@ -2089,6 +2127,8 @@ static void test_mdi(void)
|
|||
GetModuleHandleA(NULL), NULL);
|
||||
assert(mdi_hwndMain);
|
||||
|
||||
frame_menu = CreateMenu();
|
||||
|
||||
GetClientRect(mdi_hwndMain, &rc);
|
||||
|
||||
client_cs.hWindowMenu = 0;
|
||||
|
@ -2096,7 +2136,6 @@ static void test_mdi(void)
|
|||
|
||||
for (i = 0; i < sizeof(style)/sizeof(style[0]); i++)
|
||||
{
|
||||
HWND mdi_child;
|
||||
SCROLLINFO si;
|
||||
BOOL ret, gotit;
|
||||
|
||||
|
@ -2114,6 +2153,25 @@ static void test_mdi(void)
|
|||
mdi_lParam_test_message);
|
||||
ok(mdi_child != 0, "MDI child creation failed\n");
|
||||
|
||||
SendMessageW(mdi_child, WM_SIZE, SIZE_MAXIMIZED, 0);
|
||||
SetMenu(mdi_hwndMain, frame_menu);
|
||||
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child maximize, but has %u\n",
|
||||
GetMenuItemCount(frame_menu));
|
||||
|
||||
child_menu = CreateMenu();
|
||||
SendMessageW(mdi_client, WM_MDISETMENU, 0, (LPARAM)child_menu);
|
||||
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after WM_MDISETMENU, but has %u\n",
|
||||
GetMenuItemCount(frame_menu));
|
||||
|
||||
SendMessageW(mdi_child, WM_SIZE, SIZE_RESTORED, 0);
|
||||
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child restored, but has %u items\n",
|
||||
GetMenuItemCount(frame_menu));
|
||||
|
||||
SetMenu(mdi_hwndMain, NULL);
|
||||
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_ALL;
|
||||
ret = GetScrollInfo(mdi_client, SB_HORZ, &si);
|
||||
|
@ -2222,10 +2280,46 @@ todo_wine
|
|||
else
|
||||
ok(!ret, "style %#x: GetScrollInfo(SB_VERT) should fail\n", style[i]);
|
||||
|
||||
DestroyMenu(child_menu);
|
||||
DestroyWindow(mdi_child);
|
||||
DestroyWindow(mdi_client);
|
||||
}
|
||||
|
||||
SetMenu(mdi_hwndMain, frame_menu);
|
||||
|
||||
mdi_client = CreateWindowExA(0, "mdiclient", NULL,
|
||||
WS_CHILD,
|
||||
0, 0, rc.right, rc.bottom,
|
||||
mdi_hwndMain, 0, 0, &client_cs);
|
||||
ok(mdi_client != 0, "MDI client creation failed\n");
|
||||
|
||||
mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
|
||||
0,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
mdi_client, 0, 0,
|
||||
mdi_lParam_test_message);
|
||||
ok(mdi_child != 0, "MDI child creation failed\n");
|
||||
|
||||
SendMessageW(mdi_child, WM_SIZE, SIZE_MAXIMIZED, 0);
|
||||
ok(GetMenuItemCount(frame_menu) == 4, "Frame menu should have 4 items after child maximize, but has %u\n",
|
||||
GetMenuItemCount(frame_menu));
|
||||
|
||||
child_menu = CreateMenu();
|
||||
SendMessageW(mdi_client, WM_MDISETMENU, 0, (LPARAM)child_menu);
|
||||
|
||||
ok(GetMenuItemCount(frame_menu) == 4, "Frame menu should have 4 items after WM_MDISETMENU, but has %u\n",
|
||||
GetMenuItemCount(frame_menu));
|
||||
|
||||
SendMessageW(mdi_child, WM_SIZE, SIZE_RESTORED, 0);
|
||||
|
||||
ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child restored, but has %u items\n",
|
||||
GetMenuItemCount(frame_menu));
|
||||
|
||||
DestroyMenu(child_menu);
|
||||
DestroyWindow(mdi_child);
|
||||
DestroyWindow(mdi_client);
|
||||
|
||||
/* MDIClient without MDIS_ALLCHILDSTYLES */
|
||||
mdi_client = CreateWindowExA(0, "mdiclient",
|
||||
NULL,
|
||||
|
|
Loading…
Reference in New Issue