[PATCH 0/3] MR10127: user32: Respect WS_MAXIMIZEBOX of the being activated MDI child.
From: Dmitry Timoshkov <dmitry@baikal.ru> It's not enough to use "mdiclient" as a parent and specify WS_EX_MDICHILD style, for a proper MDI child it's also necessary for an MDI child to call DefMDIChildProc() for default message processing. This change is required for tests in the next patch to succeed. Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/user32/tests/win.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 921ce01299a..f320be9debf 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -2486,6 +2486,11 @@ static LRESULT WINAPI mdi_child_wnd_proc_2(HWND hwnd, UINT msg, WPARAM wparam, L return DefWindowProcA(hwnd, msg, wparam, lparam); } +static LRESULT WINAPI mdi_child_wnd_proc_3(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + return DefMDIChildProcA(hwnd, msg, wparam, lparam); +} + static LRESULT WINAPI mdi_main_wnd_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { static HWND mdi_client; @@ -2576,6 +2581,10 @@ static BOOL mdi_RegisterWindowClasses(void) cls.lpszClassName = "MDI_child_Class_2"; if(!RegisterClassA(&cls)) return FALSE; + cls.lpfnWndProc = mdi_child_wnd_proc_3; + cls.lpszClassName = "MDI_child_Class_3"; + if(!RegisterClassA(&cls)) return FALSE; + return TRUE; } @@ -8239,33 +8248,40 @@ static void test_ShowWindow_child(HWND hwndMain) DestroyWindow(hwnd); } -static void test_ShowWindow_mdichild(HWND hwndMain) +static void test_ShowWindow_mdichild(void) { RECT rect, orig, expect, nc; LPARAM ret; - HWND mdiclient, hwnd, hwnd2; + HWND mdi_hwndMain, mdiclient, hwnd, hwnd2; LONG style; POINT pt = {0}; CLIENTCREATESTRUCT mdi_client_cs = {0,1}; + mdi_hwndMain = CreateWindowExA(0, "MDI_parent_Class", "MDI parent window", + WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, + 100, 100, CW_USEDEFAULT, CW_USEDEFAULT, + GetDesktopWindow(), 0, + GetModuleHandleA(NULL), NULL); + ok(!!mdi_hwndMain, "failed to create window, error %lu\n", GetLastError()); + SetRect(&orig, 20, 20, 210, 110); GetClientRect(hwndMain, &rect); - mdiclient = CreateWindowA("mdiclient", "MDI client", WS_CHILD, + mdiclient = CreateWindowA("mdiclient", "MDI client", WS_CHILD | WS_VISIBLE, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, - hwndMain, 0, 0, &mdi_client_cs); + mdi_hwndMain, 0, 0, &mdi_client_cs); ok(!!mdiclient, "failed to create window, error %lu\n", GetLastError()); - hwnd = CreateWindowExA(WS_EX_MDICHILD, "MainWindowClass", "MDI child", + hwnd = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_3", "MDI child", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, orig.left, orig.top, orig.right - orig.left, orig.bottom - orig.top, mdiclient, 0, 0, NULL); ok(!!hwnd, "failed to create window, error %lu\n", GetLastError()); - hwnd2 = CreateWindowExA(WS_EX_MDICHILD, "MainWindowClass", "MDI child 2", + hwnd2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_3", "MDI child 2", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, orig.left, orig.top, orig.right - orig.left, orig.bottom - orig.top, mdiclient, 0, 0, NULL); ok(!!hwnd2, "failed to create window, error %lu\n", GetLastError()); - ClientToScreen(hwndMain, &pt); + ClientToScreen(mdi_hwndMain, &pt); OffsetRect(&orig, pt.x, pt.y); style = GetWindowLongA(hwnd, GWL_STYLE); @@ -8285,7 +8301,7 @@ static void test_ShowWindow_mdichild(HWND hwndMain) ok(style & WS_MINIMIZE, "window should be minimized\n"); ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); GetWindowRect(hwnd, &rect); - GetClientRect(hwndMain, &expect); + GetClientRect(mdiclient, &expect); SetRect(&expect, 0, expect.bottom - GetSystemMetrics(SM_CYMINIMIZED), GetSystemMetrics(SM_CXMINIMIZED), expect.bottom); OffsetRect(&expect, pt.x, pt.y); @@ -8336,10 +8352,10 @@ static void test_ShowWindow_mdichild(HWND hwndMain) ok(!(style & WS_DISABLED), "window should not be disabled\n"); ok(style & WS_VISIBLE, "window should be visible\n"); ok(!(style & WS_MINIMIZE), "window should be minimized\n"); - ok(style & WS_MAXIMIZE, "window should not be maximized\n"); + ok(style & WS_MAXIMIZE, "window should be maximized\n"); GetWindowRect(hwnd, &rect); - GetClientRect(hwndMain, &expect); - AdjustWindowRectEx(&expect, GetWindowLongA(hwnd, GWL_STYLE) & ~WS_BORDER, + GetClientRect(mdiclient, &expect); + AdjustWindowRectEx(&expect, GetWindowLongA(hwnd, GWL_STYLE), 0, GetWindowLongA(hwnd, GWL_EXSTYLE)); OffsetRect(&expect, pt.x, pt.y); ok(EqualRect(&expect, &rect), "expected %s, got %s\n", @@ -8367,6 +8383,7 @@ static void test_ShowWindow_mdichild(HWND hwndMain) DestroyWindow(hwnd2); DestroyWindow(hwnd); DestroyWindow(mdiclient); + DestroyWindow(mdi_hwndMain); } static DWORD CALLBACK enablewindow_thread(LPVOID arg) @@ -14500,7 +14517,7 @@ START_TEST(win) test_ShowWindow(); test_ShowWindow_owned(hwndMain); test_ShowWindow_child(hwndMain); - test_ShowWindow_mdichild(hwndMain); + test_ShowWindow_mdichild(); test_EnableWindow(); test_gettext(); test_GetUpdateRect(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10127
From: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/user32/tests/win.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index f320be9debf..d4549594c6f 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -8252,7 +8252,7 @@ static void test_ShowWindow_mdichild(void) { RECT rect, orig, expect, nc; LPARAM ret; - HWND mdi_hwndMain, mdiclient, hwnd, hwnd2; + HWND mdi_hwndMain, mdiclient, hwnd, hwnd2, hwnd3; LONG style; POINT pt = {0}; CLIENTCREATESTRUCT mdi_client_cs = {0,1}; @@ -8380,6 +8380,37 @@ static void test_ShowWindow_mdichild(void) ok(EqualRect(&orig, &rect), "expected %s, got %s\n", wine_dbgstr_rect(&orig), wine_dbgstr_rect(&rect)); + /* test switching from a maximized MDI child to a child without WS_MAXIMIZEBOX */ + ret = ShowWindow(hwnd2, SW_MAXIMIZE); + ok(ret, "wrong ret %Iu\n", ret); + style = GetWindowLongA(hwnd2, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should be minimized\n"); + ok(style & WS_MAXIMIZE, "window should be maximized\n"); + + hwnd3 = (HWND)SendMessageA(mdiclient, WM_MDIGETACTIVE, 0, 0); + ok(hwnd3 == hwnd2, "wrong active child %p\n", hwnd3); + + style = GetWindowLongA(hwnd, GWL_STYLE); + SetWindowLongA(hwnd, GWL_STYLE, style & ~WS_MAXIMIZEBOX); + + GetWindowRect(hwndMain, &rect); + trace("hwndMain window rect %s\n", wine_dbgstr_rect(&rect)); + GetWindowRect(mdiclient, &rect); + trace("mdiclient window rect %s\n", wine_dbgstr_rect(&rect)); + + SendMessageA(mdiclient, WM_MDIACTIVATE, (WPARAM)hwnd, 0); + hwnd3 = (HWND)SendMessageA(mdiclient, WM_MDIGETACTIVE, 0, 0); + ok(hwnd3 == hwnd, "wrong active child %p\n", hwnd3); + + style = GetWindowLongA(hwnd, GWL_STYLE); + ok(!(style & WS_DISABLED), "window should not be disabled\n"); + ok(style & WS_VISIBLE, "window should be visible\n"); + ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); + todo_wine + ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); + DestroyWindow(hwnd2); DestroyWindow(hwnd); DestroyWindow(mdiclient); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10127
From: Dmitry Timoshkov <dmitry@baikal.ru> Wine-Bug: http://bugs.winehq.org/show_bug.cgi?id=59361 Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> --- dlls/user32/mdi.c | 2 +- dlls/user32/tests/win.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dlls/user32/mdi.c b/dlls/user32/mdi.c index 11c7f98081f..d19990fbdb0 100644 --- a/dlls/user32/mdi.c +++ b/dlls/user32/mdi.c @@ -469,7 +469,7 @@ static void MDI_SwitchActiveChild( MDICLIENTINFO *ci, HWND hwndTo, BOOL activate { BOOL was_zoomed = IsZoomed(hwndPrev); - if (was_zoomed) + if (was_zoomed && (GetWindowLongW( hwndTo, GWL_STYLE ) & WS_MAXIMIZEBOX)) { /* restore old MDI child */ SendMessageW( hwndPrev, WM_SETREDRAW, FALSE, 0 ); diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index d4549594c6f..135b11ddac4 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -8408,7 +8408,6 @@ static void test_ShowWindow_mdichild(void) ok(!(style & WS_DISABLED), "window should not be disabled\n"); ok(style & WS_VISIBLE, "window should be visible\n"); ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); - todo_wine ok(!(style & WS_MAXIMIZE), "window should not be maximized\n"); DestroyWindow(hwnd2); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10127
participants (2)
-
Dmitry Timoshkov -
Dmitry Timoshkov (@dmitry)