Commit 1b1e0027 authored by Rein Klazes's avatar Rein Klazes Committed by Alexandre Julliard

user32: Combine horizontal and vertical window scroll bar info in a single structure.

parent 50c3b530
...@@ -406,9 +406,8 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa ...@@ -406,9 +406,8 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
if (!wndPtr) return 0; if (!wndPtr) return 0;
HeapFree( GetProcessHeap(), 0, wndPtr->text ); HeapFree( GetProcessHeap(), 0, wndPtr->text );
wndPtr->text = NULL; wndPtr->text = NULL;
HeapFree( GetProcessHeap(), 0, wndPtr->pVScroll ); HeapFree( GetProcessHeap(), 0, wndPtr->pScroll );
HeapFree( GetProcessHeap(), 0, wndPtr->pHScroll ); wndPtr->pScroll = NULL;
wndPtr->pVScroll = wndPtr->pHScroll = NULL;
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );
return 0; return 0;
} }
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(scroll); WINE_DEFAULT_DEBUG_CHANNEL(scroll);
/* data for a single scroll bar */
typedef struct typedef struct
{ {
INT curVal; /* Current scroll-bar value */ INT curVal; /* Current scroll-bar value */
...@@ -50,6 +51,12 @@ typedef struct ...@@ -50,6 +51,12 @@ typedef struct
UINT flags; /* EnableScrollBar flags */ UINT flags; /* EnableScrollBar flags */
} SCROLLBAR_INFO, *LPSCROLLBAR_INFO; } SCROLLBAR_INFO, *LPSCROLLBAR_INFO;
/* data for window that has (one or two) scroll bars */
typedef struct
{
SCROLLBAR_INFO horz;
SCROLLBAR_INFO vert;
} WINSCROLLBAR_INFO, *LPWINSCROLLBAR_INFO;
/* Minimum size of the rectangle between the arrows */ /* Minimum size of the rectangle between the arrows */
#define SCROLL_MIN_RECT 4 #define SCROLL_MIN_RECT 4
...@@ -156,26 +163,39 @@ static SCROLLBAR_INFO *SCROLL_GetInternalInfo( HWND hwnd, INT nBar, BOOL alloc ) ...@@ -156,26 +163,39 @@ static SCROLLBAR_INFO *SCROLL_GetInternalInfo( HWND hwnd, INT nBar, BOOL alloc )
if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return NULL; if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) return NULL;
switch(nBar) switch(nBar)
{ {
case SB_HORZ: infoPtr = wndPtr->pHScroll; break; case SB_HORZ:
case SB_VERT: infoPtr = wndPtr->pVScroll; break; if (wndPtr->pScroll) infoPtr = &((LPWINSCROLLBAR_INFO)wndPtr->pScroll)->horz;
case SB_CTL: infoPtr = (SCROLLBAR_INFO *)wndPtr->wExtra; break; break;
case SB_BOTH: WARN("with SB_BOTH\n"); break; case SB_VERT:
if (wndPtr->pScroll) infoPtr = &((LPWINSCROLLBAR_INFO)wndPtr->pScroll)->vert;
break;
case SB_CTL:
infoPtr = (SCROLLBAR_INFO *)wndPtr->wExtra;
break;
case SB_BOTH:
WARN("with SB_BOTH\n");
break;
} }
if (!infoPtr && alloc) if (!infoPtr && alloc)
{ {
WINSCROLLBAR_INFO *winInfoPtr;
if (nBar != SB_HORZ && nBar != SB_VERT) if (nBar != SB_HORZ && nBar != SB_VERT)
WARN("Cannot initialize nBar=%d\n",nBar); WARN("Cannot initialize nBar=%d\n",nBar);
else if ((infoPtr = HeapAlloc( GetProcessHeap(), 0, sizeof(SCROLLBAR_INFO) ))) else if ((winInfoPtr = HeapAlloc( GetProcessHeap(), 0, sizeof(WINSCROLLBAR_INFO) )))
{ {
/* Set default values */ /* Set default values */
infoPtr->minVal = infoPtr->curVal = infoPtr->page = 0; winInfoPtr->horz.minVal = 0;
/* From MSDN: max for a standard scroll bar is 100 by default. */ winInfoPtr->horz.curVal = 0;
infoPtr->maxVal = 100; winInfoPtr->horz.page = 0;
/* Scroll bar is enabled by default after create */ /* From MSDN and our own tests:
infoPtr->flags = ESB_ENABLE_BOTH; * max for a standard scroll bar is 100 by default. */
if (nBar == SB_HORZ) wndPtr->pHScroll = infoPtr; winInfoPtr->horz.maxVal = 100;
else wndPtr->pVScroll = infoPtr; winInfoPtr->horz.flags = ESB_ENABLE_BOTH;
winInfoPtr->vert = winInfoPtr->horz;
wndPtr->pScroll = winInfoPtr;
infoPtr = nBar == SB_HORZ ? &winInfoPtr->horz : &winInfoPtr->vert;
} }
} }
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );
......
...@@ -211,6 +211,7 @@ static void scrollbar_test4(void) ...@@ -211,6 +211,7 @@ static void scrollbar_test4(void)
static void scrollbar_test_default( DWORD style) static void scrollbar_test_default( DWORD style)
{ {
INT min, max, ret; INT min, max, ret;
DWORD winstyle;
HWND hwnd; HWND hwnd;
SCROLLINFO si = { sizeof( SCROLLINFO), SIF_TRACKPOS }; SCROLLINFO si = { sizeof( SCROLLINFO), SIF_TRACKPOS };
...@@ -226,6 +227,7 @@ static void scrollbar_test_default( DWORD style) ...@@ -226,6 +227,7 @@ static void scrollbar_test_default( DWORD style)
ok( min == 0 && max == 0, ok( min == 0 && max == 0,
"Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min, max, style); "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min, max, style);
else else
todo_wine
ok( min == 0 && max == 100, ok( min == 0 && max == 100,
"Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style);
ret = GetScrollRange( hwnd, SB_HORZ, &min, &max); ret = GetScrollRange( hwnd, SB_HORZ, &min, &max);
...@@ -236,6 +238,7 @@ static void scrollbar_test_default( DWORD style) ...@@ -236,6 +238,7 @@ static void scrollbar_test_default( DWORD style)
ok( min == 0 && max == 0, ok( min == 0 && max == 0,
"Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min, max, style); "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min, max, style);
else else
todo_wine
ok( min == 0 && max == 100, ok( min == 0 && max == 100,
"Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style);
/* test GetScrollInfo, vist for vertical SB */ /* test GetScrollInfo, vist for vertical SB */
...@@ -244,6 +247,7 @@ static void scrollbar_test_default( DWORD style) ...@@ -244,6 +247,7 @@ static void scrollbar_test_default( DWORD style)
if( !( style & ( WS_VSCROLL | WS_HSCROLL))) if( !( style & ( WS_VSCROLL | WS_HSCROLL)))
ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style);
else else
todo_wine
ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
/* Same for Horizontal SB */ /* Same for Horizontal SB */
ret = GetScrollInfo( hwnd, SB_HORZ, &si); ret = GetScrollInfo( hwnd, SB_HORZ, &si);
...@@ -251,6 +255,7 @@ static void scrollbar_test_default( DWORD style) ...@@ -251,6 +255,7 @@ static void scrollbar_test_default( DWORD style)
if( !( style & ( WS_VSCROLL | WS_HSCROLL))) if( !( style & ( WS_VSCROLL | WS_HSCROLL)))
ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style);
else else
todo_wine
ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
/* now set the Vertical Scroll range to something that could be the default value it /* now set the Vertical Scroll range to something that could be the default value it
* already has */; * already has */;
...@@ -260,17 +265,23 @@ static void scrollbar_test_default( DWORD style) ...@@ -260,17 +265,23 @@ static void scrollbar_test_default( DWORD style)
ret = GetScrollRange( hwnd, SB_HORZ, &min, &max); ret = GetScrollRange( hwnd, SB_HORZ, &min, &max);
ok( ret, "GetScrollRange failed.\n"); ok( ret, "GetScrollRange failed.\n");
/* now the range should be 0,100 in ALL cases */ /* now the range should be 0,100 in ALL cases */
todo_wine
ok( min == 0 && max == 100, ok( min == 0 && max == 100,
"Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style);
/* See what is different now for GetScrollRange */ /* See what is different now for GetScrollRange */
ret = GetScrollInfo( hwnd, SB_HORZ, &si); ret = GetScrollInfo( hwnd, SB_HORZ, &si);
/* should succeed in ALL cases */ /* should succeed in ALL cases */
todo_wine
ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
ret = GetScrollInfo( hwnd, SB_VERT, &si); ret = GetScrollInfo( hwnd, SB_VERT, &si);
/* should succeed in ALL cases */ /* should succeed in ALL cases */
ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
/* report the windows style */
winstyle = GetWindowLongW( hwnd, GWL_STYLE );
/* WS_VSCROLL added to the window style */
todo_wine
if( !(style & WS_VSCROLL))
ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == ( style | WS_VSCROLL),
"unexpected style change %8lx expected %8lx\n",
(winstyle & (WS_HSCROLL|WS_VSCROLL)), style | WS_VSCROLL);
/* do the test again with H and V reversed. /* do the test again with H and V reversed.
* Start with a clean window */ * Start with a clean window */
DestroyWindow( hwnd); DestroyWindow( hwnd);
...@@ -285,7 +296,6 @@ todo_wine ...@@ -285,7 +296,6 @@ todo_wine
ret = GetScrollRange( hwnd, SB_VERT, &min, &max); ret = GetScrollRange( hwnd, SB_VERT, &min, &max);
ok( ret, "GetScrollRange failed.\n"); ok( ret, "GetScrollRange failed.\n");
/* now the range should be 0,100 in ALL cases */ /* now the range should be 0,100 in ALL cases */
todo_wine
ok( min == 0 && max == 100, ok( min == 0 && max == 100,
"Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style);
/* See what is different now for GetScrollRange */ /* See what is different now for GetScrollRange */
...@@ -294,9 +304,16 @@ todo_wine ...@@ -294,9 +304,16 @@ todo_wine
ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
ret = GetScrollInfo( hwnd, SB_VERT, &si); ret = GetScrollInfo( hwnd, SB_VERT, &si);
/* should succeed in ALL cases */ /* should succeed in ALL cases */
todo_wine
ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
/* Slightly change the test to muse SetScrollInfo /* report the windows style */
winstyle = GetWindowLongW( hwnd, GWL_STYLE );
/* WS_HSCROLL added to the window style */
todo_wine
if( !(style & WS_HSCROLL))
ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == ( style | WS_HSCROLL),
"unexpected style change %8lx expected %8lx\n",
(winstyle & (WS_HSCROLL|WS_VSCROLL)), style | WS_HSCROLL);
/* Slightly change the test to use SetScrollInfo
* Start with a clean window */ * Start with a clean window */
DestroyWindow( hwnd); DestroyWindow( hwnd);
hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style, hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style,
...@@ -313,7 +330,6 @@ todo_wine ...@@ -313,7 +330,6 @@ todo_wine
ret = GetScrollRange( hwnd, SB_VERT, &min, &max); ret = GetScrollRange( hwnd, SB_VERT, &min, &max);
ok( ret, "GetScrollRange failed.\n"); ok( ret, "GetScrollRange failed.\n");
/* now the range should be 0,100 in ALL cases */ /* now the range should be 0,100 in ALL cases */
todo_wine
ok( min == 0 && max == 100, ok( min == 0 && max == 100,
"Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style);
/* See what is different now for GetScrollRange */ /* See what is different now for GetScrollRange */
...@@ -322,8 +338,30 @@ todo_wine ...@@ -322,8 +338,30 @@ todo_wine
ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
ret = GetScrollInfo( hwnd, SB_VERT, &si); ret = GetScrollInfo( hwnd, SB_VERT, &si);
/* should succeed in ALL cases */ /* should succeed in ALL cases */
todo_wine
ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
/* also test if the window scroll bars are enabled */
ret = EnableScrollBar( hwnd, SB_VERT, ESB_ENABLE_BOTH);
ok( !ret, "Vertical window scroll bar was not enabled\n");
ret = EnableScrollBar( hwnd, SB_HORZ, ESB_ENABLE_BOTH);
ok( !ret, "Horizontal window scroll bar was not enabled\n");
DestroyWindow( hwnd);
/* finally, check if adding a WS_[HV]SColl style of a window makes the scroll info
* available */
if( style & (WS_HSCROLL | WS_VSCROLL)) return;/* only test if not yet set */
/* Start with a clean window */
DestroyWindow( hwnd);
hwnd = CreateWindowExA( 0, "static", "", WS_POPUP ,
0, 0, 10, 10, 0, 0, 0, NULL);
assert( hwnd != 0);
ret = GetScrollInfo( hwnd, SB_VERT, &si);
/* should fail */
ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style);
/* add scroll styles */
winstyle = GetWindowLongW( hwnd, GWL_STYLE );
SetWindowLongW( hwnd, GWL_STYLE, winstyle | WS_VSCROLL | WS_HSCROLL);
ret = GetScrollInfo( hwnd, SB_VERT, &si);
/* should still fail */
ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style);
/* clean up */ /* clean up */
DestroyWindow( hwnd); DestroyWindow( hwnd);
} }
...@@ -359,11 +397,10 @@ START_TEST ( scroll ) ...@@ -359,11 +397,10 @@ START_TEST ( scroll )
scrollbar_test4(); scrollbar_test4();
scrollbar_test_default( 0); scrollbar_test_default( 0);
if( 0) { /* enable this when the todo's in scrollbar_test_default are fixed */
scrollbar_test_default( WS_HSCROLL); scrollbar_test_default( WS_HSCROLL);
scrollbar_test_default( WS_VSCROLL); scrollbar_test_default( WS_VSCROLL);
scrollbar_test_default( WS_HSCROLL | WS_VSCROLL); scrollbar_test_default( WS_HSCROLL | WS_VSCROLL);
}
DestroyWindow(hScroll); DestroyWindow(hScroll);
DestroyWindow(hMainWnd); DestroyWindow(hMainWnd);
} }
...@@ -1073,8 +1073,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, LPCWSTR className, UINT flags ...@@ -1073,8 +1073,7 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, LPCWSTR className, UINT flags
wndPtr->dwExStyle = cs->dwExStyle; wndPtr->dwExStyle = cs->dwExStyle;
wndPtr->wIDmenu = 0; wndPtr->wIDmenu = 0;
wndPtr->helpContext = 0; wndPtr->helpContext = 0;
wndPtr->pVScroll = NULL; wndPtr->pScroll = NULL;
wndPtr->pHScroll = NULL;
wndPtr->userdata = 0; wndPtr->userdata = 0;
wndPtr->hIcon = 0; wndPtr->hIcon = 0;
wndPtr->hIconSmall = 0; wndPtr->hIconSmall = 0;
......
...@@ -51,8 +51,7 @@ typedef struct tagWND ...@@ -51,8 +51,7 @@ typedef struct tagWND
POINT max_pos; /* Position for maximized window */ POINT max_pos; /* Position for maximized window */
HWND icon_title; /* Icon title window */ HWND icon_title; /* Icon title window */
LPWSTR text; /* Window text */ LPWSTR text; /* Window text */
void *pVScroll; /* Vertical scroll-bar info */ void *pScroll; /* Scroll-bar info */
void *pHScroll; /* Horizontal scroll-bar info */
DWORD dwStyle; /* Window style (from CreateWindow) */ DWORD dwStyle; /* Window style (from CreateWindow) */
DWORD dwExStyle; /* Extended style (from CreateWindowEx) */ DWORD dwExStyle; /* Extended style (from CreateWindowEx) */
UINT_PTR wIDmenu; /* ID or hmenu (from CreateWindow) */ UINT_PTR wIDmenu; /* ID or hmenu (from CreateWindow) */
......
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