From ecd814cca5e704e4ffdebd7609fa5593aed96393 Mon Sep 17 00:00:00 2001 From: Bruno Jesus <00cpxxx@gmail.com> Date: Fri, 20 Nov 2015 16:38:16 +0800 Subject: [PATCH] user32: Don't add scroll bars to mdiclient if the window style doesn't allow it. Signed-off-by: Bruno Jesus <00cpxxx@gmail.com> Signed-off-by: Dmitry Timoshkov Signed-off-by: Alexandre Julliard --- dlls/user32/mdi.c | 28 ++++++++++++++++++---------- dlls/user32/tests/win.c | 2 -- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/dlls/user32/mdi.c b/dlls/user32/mdi.c index d0a472a3cb8..b5a047307bc 100644 --- a/dlls/user32/mdi.c +++ b/dlls/user32/mdi.c @@ -1709,6 +1709,7 @@ void WINAPI CalcChildScroll( HWND hwnd, INT scroll ) SCROLLINFO info; RECT childRect, clientRect; HWND *list; + DWORD style; GetClientRect( hwnd, &clientRect ); SetRectEmpty( &childRect ); @@ -1718,7 +1719,7 @@ void WINAPI CalcChildScroll( HWND hwnd, INT scroll ) int i; for (i = 0; list[i]; i++) { - DWORD style = GetWindowLongW( list[i], GWL_STYLE ); + style = GetWindowLongW( list[i], GWL_STYLE ); if (style & WS_MAXIMIZE) { HeapFree( GetProcessHeap(), 0, list ); @@ -1740,22 +1741,29 @@ void WINAPI CalcChildScroll( HWND hwnd, INT scroll ) info.cbSize = sizeof(info); info.fMask = SIF_POS | SIF_RANGE; - /* set the specific */ + /* set the specific values and apply but only if window style allows */ + style = GetWindowLongW( hwnd, GWL_STYLE ); switch( scroll ) { case SB_BOTH: case SB_HORZ: - info.nMin = childRect.left; - info.nMax = childRect.right - clientRect.right; - info.nPos = clientRect.left - childRect.left; - SetScrollInfo(hwnd, SB_HORZ, &info, TRUE); + if (style & (WS_HSCROLL | WS_VSCROLL)) + { + info.nMin = childRect.left; + info.nMax = childRect.right - clientRect.right; + info.nPos = clientRect.left - childRect.left; + SetScrollInfo(hwnd, SB_HORZ, &info, TRUE); + } if (scroll == SB_HORZ) break; /* fall through */ case SB_VERT: - info.nMin = childRect.top; - info.nMax = childRect.bottom - clientRect.bottom; - info.nPos = clientRect.top - childRect.top; - SetScrollInfo(hwnd, SB_VERT, &info, TRUE); + if (style & (WS_HSCROLL | WS_VSCROLL)) + { + info.nMin = childRect.top; + info.nMax = childRect.bottom - clientRect.bottom; + info.nPos = clientRect.top - childRect.top; + SetScrollInfo(hwnd, SB_VERT, &info, TRUE); + } break; } } diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index cf4ae36e863..fc6505fa147 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -2136,7 +2136,6 @@ todo_wine ok(si.nMax != 100, "expected !100\n"); } else -todo_wine ok(!ret, "style %#x: GetScrollInfo(SB_HORZ) should fail\n", style[i]); ret = GetScrollInfo(mdi_client, SB_VERT, &si); @@ -2151,7 +2150,6 @@ todo_wine ok(si.nMax != 100, "expected !100\n"); } else -todo_wine ok(!ret, "style %#x: GetScrollInfo(SB_VERT) should fail\n", style[i]); DestroyWindow(mdi_child);