1c2c66affSColin Finck /*
2c2c66affSColin Finck * Unit tests for scrollbar
3c2c66affSColin Finck *
4c2c66affSColin Finck * Copyright 2008 Lyutin Anatoly (Etersoft)
5c2c66affSColin Finck *
6c2c66affSColin Finck * This library is free software; you can redistribute it and/or
7c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
8c2c66affSColin Finck * License as published by the Free Software Foundation; either
9c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
10c2c66affSColin Finck *
11c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
12c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
13c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14c2c66affSColin Finck * Lesser General Public License for more details.
15c2c66affSColin Finck *
16c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
17c2c66affSColin Finck * License along with this library; if not, write to the Free Software
18c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19c2c66affSColin Finck */
20c2c66affSColin Finck
21d558fc75SAmine Khaldi #include <assert.h>
22d558fc75SAmine Khaldi #include <stdarg.h>
23d558fc75SAmine Khaldi #include <stdio.h>
24d558fc75SAmine Khaldi #include <windows.h>
25d558fc75SAmine Khaldi
26d558fc75SAmine Khaldi #include "wine/test.h"
27c2c66affSColin Finck
28c2c66affSColin Finck static HWND hScroll;
29c2c66affSColin Finck static BOOL bThemeActive = FALSE;
30c2c66affSColin Finck
MyWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)31c2c66affSColin Finck static LRESULT CALLBACK MyWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
32c2c66affSColin Finck {
33c2c66affSColin Finck switch(msg)
34c2c66affSColin Finck {
35c2c66affSColin Finck
36c2c66affSColin Finck case WM_CREATE:
37c2c66affSColin Finck {
38c2c66affSColin Finck hScroll = CreateWindowA( "SCROLLBAR", "", WS_CHILD | WS_VISIBLE, 0, 0, 120, 100, hWnd, (HMENU)100, GetModuleHandleA(0), 0 );
39c2c66affSColin Finck
40c2c66affSColin Finck return 0;
41c2c66affSColin Finck }
42c2c66affSColin Finck case WM_DESTROY:
43c2c66affSColin Finck PostQuitMessage(0);
44c2c66affSColin Finck break;
45c2c66affSColin Finck case WM_HSCROLL:
46c2c66affSColin Finck case WM_VSCROLL:
47c2c66affSColin Finck /* stop tracking */
48c2c66affSColin Finck ReleaseCapture();
49c2c66affSColin Finck return 0;
50c2c66affSColin Finck default:
51c2c66affSColin Finck return DefWindowProcA(hWnd, msg, wParam, lParam);
52c2c66affSColin Finck }
53c2c66affSColin Finck return 0;
54c2c66affSColin Finck }
55c2c66affSColin Finck
create_main_test_wnd(void)56c2c66affSColin Finck static HWND create_main_test_wnd(void)
57c2c66affSColin Finck {
58c2c66affSColin Finck HWND hMainWnd;
59c2c66affSColin Finck
60c2c66affSColin Finck hScroll = NULL;
61c2c66affSColin Finck hMainWnd = CreateWindowExA( 0, "MyTestWnd", "Scroll",
62c2c66affSColin Finck WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL,
63c2c66affSColin Finck CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0 );
64c2c66affSColin Finck ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n");
65c2c66affSColin Finck ok(hScroll != NULL, "got NULL scroll bar handle\n");
66c2c66affSColin Finck
67c2c66affSColin Finck return hMainWnd;
68c2c66affSColin Finck }
69c2c66affSColin Finck
scrollbar_test_track(void)70c2c66affSColin Finck static void scrollbar_test_track(void)
71c2c66affSColin Finck {
72c2c66affSColin Finck HWND mainwnd;
73c2c66affSColin Finck
74c2c66affSColin Finck mainwnd = create_main_test_wnd();
75c2c66affSColin Finck
76c2c66affSColin Finck /* test that scrollbar tracking is terminated when
77c2c66affSColin Finck * the control loses mouse capture */
78c2c66affSColin Finck SendMessageA( hScroll, WM_LBUTTONDOWN, 0, MAKELPARAM( 1, 1));
79c2c66affSColin Finck /* a normal return from SendMessage */
80c2c66affSColin Finck /* not normal for instances such as closing the window */
81c2c66affSColin Finck ok( IsWindow( hScroll), "Scrollbar has gone!\n");
82c2c66affSColin Finck
83c2c66affSColin Finck DestroyWindow(hScroll);
84c2c66affSColin Finck DestroyWindow(mainwnd);
85c2c66affSColin Finck }
86c2c66affSColin Finck
test_EnableScrollBar(void)87c2c66affSColin Finck static void test_EnableScrollBar(void)
88c2c66affSColin Finck {
89c2c66affSColin Finck HWND mainwnd;
90c2c66affSColin Finck BOOL ret;
91c2c66affSColin Finck
92c2c66affSColin Finck mainwnd = create_main_test_wnd();
93c2c66affSColin Finck
94c2c66affSColin Finck ret = EnableScrollBar( hScroll, SB_CTL, ESB_DISABLE_BOTH );
95c2c66affSColin Finck ok( ret, "The scrollbar should be disabled.\n" );
96c2c66affSColin Finck ok( !IsWindowEnabled( hScroll ), "The scrollbar window should be disabled.\n" );
97c2c66affSColin Finck
98c2c66affSColin Finck ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH );
99c2c66affSColin Finck ok( ret, "The scrollbar should be enabled.\n" );
100c2c66affSColin Finck ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" );
101c2c66affSColin Finck
102c2c66affSColin Finck /* test buttons separately */
103c2c66affSColin Finck ret = EnableScrollBar( hScroll, SB_CTL, ESB_DISABLE_LTUP );
104c2c66affSColin Finck ok( ret, "The scrollbar LTUP button should be disabled.\n" );
105c2c66affSColin Finck ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" );
106c2c66affSColin Finck ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH );
107c2c66affSColin Finck ok( ret, "The scrollbar should be enabled.\n" );
108c2c66affSColin Finck ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" );
109c2c66affSColin Finck
110c2c66affSColin Finck ret = EnableScrollBar( hScroll, SB_CTL, ESB_DISABLE_RTDN );
111c2c66affSColin Finck ok( ret, "The scrollbar RTDN button should be disabled.\n" );
112c2c66affSColin Finck ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" );
113c2c66affSColin Finck ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH );
114c2c66affSColin Finck ok( ret, "The scrollbar should be enabled.\n" );
115c2c66affSColin Finck ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" );
116c2c66affSColin Finck
117*7a62c32bSAmine Khaldi SetLastError( 0xdeadbeef );
118*7a62c32bSAmine Khaldi ret = EnableScrollBar( mainwnd, SB_CTL, ESB_ENABLE_BOTH );
119*7a62c32bSAmine Khaldi ok( !ret, "EnableScrollBar should fail.\n" );
120*7a62c32bSAmine Khaldi todo_wine
121*7a62c32bSAmine Khaldi ok( GetLastError() == ERROR_INVALID_PARAMETER
122*7a62c32bSAmine Khaldi || broken(GetLastError() == 0xdeadbeef), /* winxp */
123*7a62c32bSAmine Khaldi "GetLastError() = %u\n", GetLastError() );
124*7a62c32bSAmine Khaldi
125c2c66affSColin Finck /* disable window, try to re-enable */
126c2c66affSColin Finck ret = EnableWindow( hScroll, FALSE );
127c2c66affSColin Finck ok( !ret, "got %d\n", ret );
128c2c66affSColin Finck ok( !IsWindowEnabled( hScroll ), "The scrollbar window should be disabled.\n" );
129c2c66affSColin Finck
130c2c66affSColin Finck ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH );
131c2c66affSColin Finck ok( ret, "got %d\n", ret );
132c2c66affSColin Finck ok( IsWindowEnabled( hScroll ), "The scrollbar window should be disabled.\n" );
133c2c66affSColin Finck
134c2c66affSColin Finck DestroyWindow(hScroll);
135c2c66affSColin Finck DestroyWindow(mainwnd);
136c2c66affSColin Finck }
137c2c66affSColin Finck
test_SetScrollPos(void)138c2c66affSColin Finck static void test_SetScrollPos(void)
139c2c66affSColin Finck {
140c2c66affSColin Finck HWND mainwnd;
141c2c66affSColin Finck int ret;
142c2c66affSColin Finck
143c2c66affSColin Finck mainwnd = create_main_test_wnd();
144c2c66affSColin Finck
145c2c66affSColin Finck EnableWindow( hScroll, FALSE );
146c2c66affSColin Finck ok( !IsWindowEnabled( hScroll ), "The scroll should be disabled.\n" );
147c2c66affSColin Finck
148c2c66affSColin Finck ret = SetScrollPos( hScroll, SB_CTL, 30, TRUE);
149c2c66affSColin Finck ok( !ret, "The position should not be set.\n" );
150c2c66affSColin Finck
151c2c66affSColin Finck ret = GetScrollPos( hScroll, SB_CTL);
152c2c66affSColin Finck ok( !ret, "The position should be equal to zero\n");
153c2c66affSColin Finck
154c2c66affSColin Finck ret = SetScrollRange( hScroll, SB_CTL, 0, 100, TRUE );
155c2c66affSColin Finck ok( ret, "The range should be set.\n" );
156c2c66affSColin Finck
157c2c66affSColin Finck ret = SetScrollPos( hScroll, SB_CTL, 30, TRUE);
158c2c66affSColin Finck ok( !ret , "The position should not be set.\n" );
159c2c66affSColin Finck
160c2c66affSColin Finck ret = GetScrollPos( hScroll, SB_CTL);
161c2c66affSColin Finck ok( ret == 30, "The position should be set!!!\n");
162c2c66affSColin Finck
163c2c66affSColin Finck EnableWindow( hScroll, TRUE );
164c2c66affSColin Finck ok( IsWindowEnabled( hScroll ), "The scroll should be enabled.\n" );
165c2c66affSColin Finck
166c2c66affSColin Finck ret = SetScrollPos( hScroll, SB_CTL, 30, TRUE);
167c2c66affSColin Finck ok( ret == 30, "The position should be set.\n" );
168c2c66affSColin Finck
169c2c66affSColin Finck ret = GetScrollPos( hScroll, SB_CTL);
170c2c66affSColin Finck ok( ret == 30, "The position should not be equal to zero\n");
171c2c66affSColin Finck
172c2c66affSColin Finck ret = SetScrollRange( hScroll, SB_CTL, 0, 100, TRUE );
173c2c66affSColin Finck ok( ret, "The range should be set.\n" );
174c2c66affSColin Finck
175c2c66affSColin Finck ret = SetScrollPos( hScroll, SB_CTL, 30, TRUE);
176c2c66affSColin Finck ok( ret == 30, "The position should be set.\n" );
177c2c66affSColin Finck
178c2c66affSColin Finck ret = GetScrollPos( hScroll, SB_CTL);
179c2c66affSColin Finck ok( ret == 30, "The position should not be equal to zero\n");
180c2c66affSColin Finck
181*7a62c32bSAmine Khaldi SetLastError( 0xdeadbeef );
182*7a62c32bSAmine Khaldi ret = SetScrollPos( mainwnd, SB_CTL, 30, TRUE );
183*7a62c32bSAmine Khaldi ok( !ret, "The position should not be set.\n" );
184*7a62c32bSAmine Khaldi ok( GetLastError() == 0xdeadbeef, "GetLastError() = %u\n", GetLastError() );
185*7a62c32bSAmine Khaldi
186*7a62c32bSAmine Khaldi SetLastError( 0xdeadbeef );
187*7a62c32bSAmine Khaldi ret = GetScrollPos( mainwnd, SB_CTL );
188*7a62c32bSAmine Khaldi ok( !ret, "The position should be equal to zero\n");
189*7a62c32bSAmine Khaldi ok( GetLastError() == 0xdeadbeef, "GetLastError() = %u\n", GetLastError() );
190*7a62c32bSAmine Khaldi
191c2c66affSColin Finck DestroyWindow(hScroll);
192c2c66affSColin Finck DestroyWindow(mainwnd);
193c2c66affSColin Finck }
194c2c66affSColin Finck
test_ShowScrollBar(void)195c2c66affSColin Finck static void test_ShowScrollBar(void)
196c2c66affSColin Finck {
197c2c66affSColin Finck HWND mainwnd;
198c2c66affSColin Finck BOOL ret;
199c2c66affSColin Finck
200c2c66affSColin Finck mainwnd = create_main_test_wnd();
201c2c66affSColin Finck
202c2c66affSColin Finck ret = ShowScrollBar( hScroll, SB_CTL, FALSE );
203c2c66affSColin Finck ok( ret, "The ShowScrollBar() should not failed.\n" );
204c2c66affSColin Finck ok( !IsWindowVisible( hScroll ), "The scrollbar window should not be visible\n" );
205c2c66affSColin Finck
206c2c66affSColin Finck ret = ShowScrollBar( hScroll, SB_CTL, TRUE );
207c2c66affSColin Finck ok( ret, "The ShowScrollBar() should not failed.\n" );
208c2c66affSColin Finck ok( !IsWindowVisible( hScroll ), "The scrollbar window should be visible\n" );
209c2c66affSColin Finck
210c2c66affSColin Finck ret = ShowScrollBar( NULL, SB_CTL, TRUE );
211c2c66affSColin Finck ok( !ret, "The ShowScrollBar() should failed.\n" );
212c2c66affSColin Finck
213*7a62c32bSAmine Khaldi ret = ShowScrollBar( mainwnd, SB_CTL, TRUE );
214*7a62c32bSAmine Khaldi ok( ret, "The ShowScrollBar() should not fail.\n" );
215*7a62c32bSAmine Khaldi
216c2c66affSColin Finck DestroyWindow(hScroll);
217c2c66affSColin Finck DestroyWindow(mainwnd);
218c2c66affSColin Finck }
219c2c66affSColin Finck
test_GetScrollBarInfo(void)220c2c66affSColin Finck static void test_GetScrollBarInfo(void)
221c2c66affSColin Finck {
222c2c66affSColin Finck HWND hMainWnd;
223c2c66affSColin Finck BOOL ret;
224c2c66affSColin Finck SCROLLBARINFO sbi;
225c2c66affSColin Finck RECT rect;
226c2c66affSColin Finck BOOL (WINAPI *pGetScrollBarInfo)(HWND, LONG, LPSCROLLBARINFO);
227c2c66affSColin Finck
228c2c66affSColin Finck pGetScrollBarInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetScrollBarInfo");
229c2c66affSColin Finck if (!pGetScrollBarInfo)
230c2c66affSColin Finck {
231c2c66affSColin Finck win_skip("GetScrollBarInfo is not available\n");
232c2c66affSColin Finck return;
233c2c66affSColin Finck }
234c2c66affSColin Finck
235c2c66affSColin Finck hMainWnd = create_main_test_wnd();
236c2c66affSColin Finck
237c2c66affSColin Finck /* Test GetScrollBarInfo to make sure it returns rcScrollBar in screen
238c2c66affSColin Finck * coordinates. */
239c2c66affSColin Finck sbi.cbSize = sizeof(sbi);
240c2c66affSColin Finck ret = pGetScrollBarInfo( hScroll, OBJID_CLIENT, &sbi);
241c2c66affSColin Finck ok( ret, "The GetScrollBarInfo() call should not fail.\n" );
242c2c66affSColin Finck GetWindowRect( hScroll, &rect );
243c2c66affSColin Finck ok( ret, "The GetWindowRect() call should not fail.\n" );
244c2c66affSColin Finck ok( !(sbi.rgstate[0] & (STATE_SYSTEM_INVISIBLE|STATE_SYSTEM_OFFSCREEN)),
245c2c66affSColin Finck "unexpected rgstate(0x%x)\n", sbi.rgstate[0]);
246c2c66affSColin Finck ok(EqualRect(&rect, &sbi.rcScrollBar), "WindowRect %s != rcScrollBar %s\n",
247c2c66affSColin Finck wine_dbgstr_rect(&rect), wine_dbgstr_rect(&sbi.rcScrollBar));
248c2c66affSColin Finck
249c2c66affSColin Finck /* Test windows horizontal and vertical scrollbar to make sure rcScrollBar
250c2c66affSColin Finck * is still returned in screen coordinates by moving the window, and
251c2c66affSColin Finck * making sure that it shifts the rcScrollBar value. */
252c2c66affSColin Finck ShowWindow( hMainWnd, SW_SHOW );
253c2c66affSColin Finck sbi.cbSize = sizeof(sbi);
254c2c66affSColin Finck ret = pGetScrollBarInfo( hMainWnd, OBJID_HSCROLL, &sbi);
255c2c66affSColin Finck ok( ret, "The GetScrollBarInfo() call should not fail.\n" );
256c2c66affSColin Finck GetWindowRect( hMainWnd, &rect );
257c2c66affSColin Finck ok( ret, "The GetWindowRect() call should not fail.\n" );
258c2c66affSColin Finck MoveWindow( hMainWnd, rect.left+5, rect.top+5,
259c2c66affSColin Finck rect.right-rect.left, rect.bottom-rect.top, TRUE );
260c2c66affSColin Finck rect = sbi.rcScrollBar;
261c2c66affSColin Finck OffsetRect(&rect, 5, 5);
262c2c66affSColin Finck ret = pGetScrollBarInfo( hMainWnd, OBJID_HSCROLL, &sbi);
263c2c66affSColin Finck ok( ret, "The GetScrollBarInfo() call should not fail.\n" );
264c2c66affSColin Finck ok(EqualRect(&rect, &sbi.rcScrollBar), "PreviousRect %s != CurrentRect %s\n",
265c2c66affSColin Finck wine_dbgstr_rect(&rect), wine_dbgstr_rect(&sbi.rcScrollBar));
266c2c66affSColin Finck
267c2c66affSColin Finck sbi.cbSize = sizeof(sbi);
268c2c66affSColin Finck ret = pGetScrollBarInfo( hMainWnd, OBJID_VSCROLL, &sbi);
269c2c66affSColin Finck ok( ret, "The GetScrollBarInfo() call should not fail.\n" );
270c2c66affSColin Finck GetWindowRect( hMainWnd, &rect );
271c2c66affSColin Finck ok( ret, "The GetWindowRect() call should not fail.\n" );
272c2c66affSColin Finck MoveWindow( hMainWnd, rect.left+5, rect.top+5,
273c2c66affSColin Finck rect.right-rect.left, rect.bottom-rect.top, TRUE );
274c2c66affSColin Finck rect = sbi.rcScrollBar;
275c2c66affSColin Finck OffsetRect(&rect, 5, 5);
276c2c66affSColin Finck ret = pGetScrollBarInfo( hMainWnd, OBJID_VSCROLL, &sbi);
277c2c66affSColin Finck ok( ret, "The GetScrollBarInfo() call should not fail.\n" );
278c2c66affSColin Finck ok(EqualRect(&rect, &sbi.rcScrollBar), "PreviousRect %s != CurrentRect %s\n",
279c2c66affSColin Finck wine_dbgstr_rect(&rect), wine_dbgstr_rect(&sbi.rcScrollBar));
280c2c66affSColin Finck
281c2c66affSColin Finck DestroyWindow(hScroll);
282c2c66affSColin Finck DestroyWindow(hMainWnd);
283c2c66affSColin Finck }
284c2c66affSColin Finck
285c2c66affSColin Finck /* some tests designed to show that Horizontal and Vertical
286c2c66affSColin Finck * window scroll bar info are not created independently */
scrollbar_test_default(DWORD style)287c2c66affSColin Finck static void scrollbar_test_default( DWORD style)
288c2c66affSColin Finck {
289c2c66affSColin Finck INT min, max, ret;
290c2c66affSColin Finck DWORD winstyle;
291c2c66affSColin Finck HWND hwnd;
292c2c66affSColin Finck SCROLLINFO si = { sizeof( SCROLLINFO), SIF_TRACKPOS };
293c2c66affSColin Finck
294c2c66affSColin Finck hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style,
295c2c66affSColin Finck 0, 0, 10, 10, 0, 0, 0, NULL);
296c2c66affSColin Finck assert( hwnd != 0);
297c2c66affSColin Finck
298c2c66affSColin Finck ret = GetScrollRange( hwnd, SB_VERT, &min, &max);
299c2c66affSColin Finck ok( ret ||
300c2c66affSColin Finck broken( !ret) /* Win 9x/ME */ , "GetScrollRange failed.\n");
301c2c66affSColin Finck /* range is 0,0 if there are no H or V scroll bars. 0,100 otherwise */
302c2c66affSColin Finck if( !( style & ( WS_VSCROLL | WS_HSCROLL)))
303c2c66affSColin Finck ok( min == 0 && max == 0,
304c2c66affSColin Finck "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min, max, style);
305c2c66affSColin Finck else
306c2c66affSColin Finck ok(( min == 0 && max == 100) ||
307c2c66affSColin Finck broken( min == 0 && max == 0), /* Win 9x/ME */
308c2c66affSColin Finck "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style);
309c2c66affSColin Finck ret = GetScrollRange( hwnd, SB_HORZ, &min, &max);
310c2c66affSColin Finck ok( ret ||
311c2c66affSColin Finck broken( !ret) /* Win 9x/ME */ , "GetScrollRange failed.\n");
312c2c66affSColin Finck /* range is 0,0 if there are no H or V scroll bars. 0,100 otherwise */
313c2c66affSColin Finck if( !( style & ( WS_VSCROLL | WS_HSCROLL)))
314c2c66affSColin Finck ok( min == 0 && max == 0,
315c2c66affSColin Finck "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min, max, style);
316c2c66affSColin Finck else
317c2c66affSColin Finck ok(( min == 0 && max == 100) ||
318c2c66affSColin Finck broken( min == 0 && max == 0), /* Win 9x/ME */
319c2c66affSColin Finck "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style);
320c2c66affSColin Finck /* test GetScrollInfo, vist for vertical SB */
321c2c66affSColin Finck ret = GetScrollInfo( hwnd, SB_VERT, &si);
322c2c66affSColin Finck /* should fail if no H or V scroll bar styles are present. Succeed otherwise */
323c2c66affSColin Finck if( !( style & ( WS_VSCROLL | WS_HSCROLL)))
324c2c66affSColin Finck ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style);
325c2c66affSColin Finck else
326c2c66affSColin Finck ok( ret ||
327c2c66affSColin Finck broken( !ret), /* Win 9x/ME */
328c2c66affSColin Finck "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
329c2c66affSColin Finck /* Same for Horizontal SB */
330c2c66affSColin Finck ret = GetScrollInfo( hwnd, SB_HORZ, &si);
331c2c66affSColin Finck /* should fail if no H or V scroll bar styles are present. Succeed otherwise */
332c2c66affSColin Finck if( !( style & ( WS_VSCROLL | WS_HSCROLL)))
333c2c66affSColin Finck ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style);
334c2c66affSColin Finck else
335c2c66affSColin Finck ok( ret ||
336c2c66affSColin Finck broken( !ret), /* Win 9x/ME */
337c2c66affSColin Finck "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
338c2c66affSColin Finck /* now set the Vertical Scroll range to something that could be the default value it
339c2c66affSColin Finck * already has */;
340c2c66affSColin Finck ret = SetScrollRange( hwnd, SB_VERT, 0, 100, FALSE);
341c2c66affSColin Finck ok( ret, "SetScrollRange failed.\n");
342c2c66affSColin Finck /* and request the Horizontal range */
343c2c66affSColin Finck ret = GetScrollRange( hwnd, SB_HORZ, &min, &max);
344c2c66affSColin Finck ok( ret, "GetScrollRange failed.\n");
345c2c66affSColin Finck /* now the range should be 0,100 in ALL cases */
346c2c66affSColin Finck ok( min == 0 && max == 100,
347c2c66affSColin Finck "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style);
348c2c66affSColin Finck /* See what is different now for GetScrollRange */
349c2c66affSColin Finck ret = GetScrollInfo( hwnd, SB_HORZ, &si);
350c2c66affSColin Finck /* should succeed in ALL cases */
351c2c66affSColin Finck ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
352c2c66affSColin Finck ret = GetScrollInfo( hwnd, SB_VERT, &si);
353c2c66affSColin Finck /* should succeed in ALL cases */
354c2c66affSColin Finck ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
355c2c66affSColin Finck /* report the windows style */
356c2c66affSColin Finck winstyle = GetWindowLongA( hwnd, GWL_STYLE );
357c2c66affSColin Finck /* WS_VSCROLL added to the window style */
358c2c66affSColin Finck if( !(style & WS_VSCROLL))
359c2c66affSColin Finck {
360c2c66affSColin Finck if (bThemeActive || style != WS_HSCROLL)
361c2c66affSColin Finck todo_wine
362c2c66affSColin Finck ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == ( style | WS_VSCROLL),
363c2c66affSColin Finck "unexpected style change %08x/%08x\n", winstyle, style);
364c2c66affSColin Finck else
365c2c66affSColin Finck ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == style,
366c2c66affSColin Finck "unexpected style change %08x/%08x\n", winstyle, style);
367c2c66affSColin Finck }
368c2c66affSColin Finck /* do the test again with H and V reversed.
369c2c66affSColin Finck * Start with a clean window */
370c2c66affSColin Finck DestroyWindow( hwnd);
371c2c66affSColin Finck hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style,
372c2c66affSColin Finck 0, 0, 10, 10, 0, 0, 0, NULL);
373c2c66affSColin Finck assert( hwnd != 0);
374c2c66affSColin Finck /* Set Horizontal Scroll range to something that could be the default value it
375c2c66affSColin Finck * already has */;
376c2c66affSColin Finck ret = SetScrollRange( hwnd, SB_HORZ, 0, 100, FALSE);
377c2c66affSColin Finck ok( ret, "SetScrollRange failed.\n");
378c2c66affSColin Finck /* and request the Vertical range */
379c2c66affSColin Finck ret = GetScrollRange( hwnd, SB_VERT, &min, &max);
380c2c66affSColin Finck ok( ret, "GetScrollRange failed.\n");
381c2c66affSColin Finck /* now the range should be 0,100 in ALL cases */
382c2c66affSColin Finck ok( min == 0 && max == 100,
383c2c66affSColin Finck "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style);
384c2c66affSColin Finck /* See what is different now for GetScrollRange */
385c2c66affSColin Finck ret = GetScrollInfo( hwnd, SB_HORZ, &si);
386c2c66affSColin Finck /* should succeed in ALL cases */
387c2c66affSColin Finck ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
388c2c66affSColin Finck ret = GetScrollInfo( hwnd, SB_VERT, &si);
389c2c66affSColin Finck /* should succeed in ALL cases */
390c2c66affSColin Finck ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
391c2c66affSColin Finck /* report the windows style */
392c2c66affSColin Finck winstyle = GetWindowLongA( hwnd, GWL_STYLE );
393c2c66affSColin Finck /* WS_HSCROLL added to the window style */
394c2c66affSColin Finck if( !(style & WS_HSCROLL))
395c2c66affSColin Finck {
396c2c66affSColin Finck if (bThemeActive || style != WS_VSCROLL)
397c2c66affSColin Finck todo_wine
398c2c66affSColin Finck ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == ( style | WS_HSCROLL),
399c2c66affSColin Finck "unexpected style change %08x/%08x\n", winstyle, style);
400c2c66affSColin Finck else
401c2c66affSColin Finck ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == style,
402c2c66affSColin Finck "unexpected style change %08x/%08x\n", winstyle, style);
403c2c66affSColin Finck }
404c2c66affSColin Finck /* Slightly change the test to use SetScrollInfo
405c2c66affSColin Finck * Start with a clean window */
406c2c66affSColin Finck DestroyWindow( hwnd);
407c2c66affSColin Finck hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style,
408c2c66affSColin Finck 0, 0, 10, 10, 0, 0, 0, NULL);
409c2c66affSColin Finck assert( hwnd != 0);
410c2c66affSColin Finck /* set Horizontal position with SetScrollInfo */
411c2c66affSColin Finck si.nPos = 0;
412c2c66affSColin Finck si.nMin = 11;
413c2c66affSColin Finck si.nMax = 22;
414c2c66affSColin Finck si.fMask |= SIF_RANGE;
415c2c66affSColin Finck ret = SetScrollInfo( hwnd, SB_HORZ, &si, FALSE);
416c2c66affSColin Finck ok( ret, "SetScrollInfo failed. Style is %08x\n", style);
417c2c66affSColin Finck /* and request the Vertical range */
418c2c66affSColin Finck ret = GetScrollRange( hwnd, SB_VERT, &min, &max);
419c2c66affSColin Finck ok( ret, "GetScrollRange failed.\n");
420c2c66affSColin Finck /* now the range should be 0,100 in ALL cases */
421c2c66affSColin Finck ok( min == 0 && max == 100,
422c2c66affSColin Finck "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style);
423c2c66affSColin Finck /* See what is different now for GetScrollRange */
424c2c66affSColin Finck ret = GetScrollInfo( hwnd, SB_HORZ, &si);
425c2c66affSColin Finck /* should succeed in ALL cases */
426c2c66affSColin Finck ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
427c2c66affSColin Finck ret = GetScrollInfo( hwnd, SB_VERT, &si);
428c2c66affSColin Finck /* should succeed in ALL cases */
429c2c66affSColin Finck ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style);
430c2c66affSColin Finck /* also test if the window scroll bars are enabled */
431c2c66affSColin Finck ret = EnableScrollBar( hwnd, SB_VERT, ESB_ENABLE_BOTH);
432c2c66affSColin Finck ok( !ret, "Vertical window scroll bar was not enabled\n");
433c2c66affSColin Finck ret = EnableScrollBar( hwnd, SB_HORZ, ESB_ENABLE_BOTH);
434c2c66affSColin Finck ok( !ret, "Horizontal window scroll bar was not enabled\n");
435c2c66affSColin Finck DestroyWindow( hwnd);
436c2c66affSColin Finck /* finally, check if adding a WS_[HV]SCROLL style of a window makes the scroll info
437c2c66affSColin Finck * available */
438c2c66affSColin Finck if( style & (WS_HSCROLL | WS_VSCROLL)) return;/* only test if not yet set */
439c2c66affSColin Finck /* Start with a clean window */
440c2c66affSColin Finck DestroyWindow( hwnd);
441c2c66affSColin Finck hwnd = CreateWindowExA( 0, "static", "", WS_POPUP ,
442c2c66affSColin Finck 0, 0, 10, 10, 0, 0, 0, NULL);
443c2c66affSColin Finck assert( hwnd != 0);
444c2c66affSColin Finck ret = GetScrollInfo( hwnd, SB_VERT, &si);
445c2c66affSColin Finck /* should fail */
446c2c66affSColin Finck ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style);
447c2c66affSColin Finck /* add scroll styles */
448c2c66affSColin Finck winstyle = GetWindowLongA( hwnd, GWL_STYLE );
449c2c66affSColin Finck SetWindowLongW( hwnd, GWL_STYLE, winstyle | WS_VSCROLL | WS_HSCROLL);
450c2c66affSColin Finck ret = GetScrollInfo( hwnd, SB_VERT, &si);
451c2c66affSColin Finck /* should still fail */
452c2c66affSColin Finck ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style);
453c2c66affSColin Finck /* clean up */
454c2c66affSColin Finck DestroyWindow( hwnd);
455c2c66affSColin Finck }
456c2c66affSColin Finck
scroll_init_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)457c2c66affSColin Finck static LRESULT CALLBACK scroll_init_proc(HWND hwnd, UINT msg,
458c2c66affSColin Finck WPARAM wparam, LPARAM lparam)
459c2c66affSColin Finck {
460c2c66affSColin Finck SCROLLINFO horz, vert;
461c2c66affSColin Finck CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam;
462c2c66affSColin Finck BOOL h_ret, v_ret;
463c2c66affSColin Finck
464c2c66affSColin Finck switch(msg)
465c2c66affSColin Finck {
466c2c66affSColin Finck case WM_NCCREATE:
467c2c66affSColin Finck return cs->lpCreateParams ? DefWindowProcA(hwnd, msg, wparam, lparam) :
468c2c66affSColin Finck TRUE;
469c2c66affSColin Finck
470c2c66affSColin Finck case WM_CREATE:
471c2c66affSColin Finck horz.cbSize = sizeof horz;
472c2c66affSColin Finck horz.fMask = SIF_ALL;
473c2c66affSColin Finck horz.nMin = 0xdeadbeaf;
474c2c66affSColin Finck horz.nMax = 0xbaadc0de;
475c2c66affSColin Finck vert = horz;
476c2c66affSColin Finck h_ret = GetScrollInfo(hwnd, SB_HORZ, &horz);
477c2c66affSColin Finck v_ret = GetScrollInfo(hwnd, SB_VERT, &vert);
478c2c66affSColin Finck
479c2c66affSColin Finck if(cs->lpCreateParams)
480c2c66affSColin Finck {
481c2c66affSColin Finck /* WM_NCCREATE was passed to DefWindowProc */
482c2c66affSColin Finck if(cs->style & (WS_VSCROLL | WS_HSCROLL))
483c2c66affSColin Finck {
484c2c66affSColin Finck ok(h_ret && v_ret, "GetScrollInfo() should return NON-zero "
485c2c66affSColin Finck "but got h_ret=%d v_ret=%d\n", h_ret, v_ret);
486c2c66affSColin Finck ok(vert.nMin == 0 && vert.nMax == 100,
487c2c66affSColin Finck "unexpected init values(SB_VERT): min=%d max=%d\n",
488c2c66affSColin Finck vert.nMin, vert.nMax);
489c2c66affSColin Finck ok(horz.nMin == 0 && horz.nMax == 100,
490c2c66affSColin Finck "unexpected init values(SB_HORZ): min=%d max=%d\n",
491c2c66affSColin Finck horz.nMin, horz.nMax);
492c2c66affSColin Finck }
493c2c66affSColin Finck else
494c2c66affSColin Finck {
495c2c66affSColin Finck ok(!h_ret && !v_ret, "GetScrollInfo() should return zeru, "
496c2c66affSColin Finck "but got h_ret=%d v_ret=%d\n", h_ret, v_ret);
497c2c66affSColin Finck ok(vert.nMin == 0xdeadbeaf && vert.nMax == 0xbaadc0de,
498c2c66affSColin Finck "unexpected initialization(SB_VERT): min=%d max=%d\n",
499c2c66affSColin Finck vert.nMin, vert.nMax);
500c2c66affSColin Finck ok(horz.nMin == 0xdeadbeaf && horz.nMax == 0xbaadc0de,
501c2c66affSColin Finck "unexpected initialization(SB_HORZ): min=%d max=%d\n",
502c2c66affSColin Finck horz.nMin, horz.nMax);
503c2c66affSColin Finck }
504c2c66affSColin Finck }
505c2c66affSColin Finck else
506c2c66affSColin Finck {
507c2c66affSColin Finck ok(!h_ret && !v_ret, "GetScrollInfo() should return zeru, "
508c2c66affSColin Finck "but got h_ret=%d v_ret=%d\n", h_ret, v_ret);
509c2c66affSColin Finck ok(horz.nMin == 0xdeadbeaf && horz.nMax == 0xbaadc0de &&
510c2c66affSColin Finck vert.nMin == 0xdeadbeaf && vert.nMax == 0xbaadc0de,
511c2c66affSColin Finck "unexpected initialization\n");
512c2c66affSColin Finck }
513c2c66affSColin Finck return FALSE; /* abort creation */
514c2c66affSColin Finck
515c2c66affSColin Finck default:
516c2c66affSColin Finck /* need for WM_GETMINMAXINFO, which precedes WM_NCCREATE */
517c2c66affSColin Finck return 0;
518c2c66affSColin Finck }
519c2c66affSColin Finck }
520c2c66affSColin Finck
scrollbar_test_init(void)521c2c66affSColin Finck static void scrollbar_test_init(void)
522c2c66affSColin Finck {
523c2c66affSColin Finck WNDCLASSEXA wc;
524c2c66affSColin Finck CHAR cls_name[] = "scroll_test_class";
525c2c66affSColin Finck LONG style[] = {WS_VSCROLL, WS_HSCROLL, WS_VSCROLL | WS_HSCROLL, 0};
526c2c66affSColin Finck int i;
527c2c66affSColin Finck
528c2c66affSColin Finck memset( &wc, 0, sizeof wc );
529c2c66affSColin Finck wc.cbSize = sizeof wc;
530c2c66affSColin Finck wc.style = CS_VREDRAW | CS_HREDRAW;
531c2c66affSColin Finck wc.hInstance = GetModuleHandleA(0);
532c2c66affSColin Finck wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
533c2c66affSColin Finck wc.hbrBackground = GetStockObject(WHITE_BRUSH);
534c2c66affSColin Finck wc.lpszClassName = cls_name;
535c2c66affSColin Finck wc.lpfnWndProc = scroll_init_proc;
536c2c66affSColin Finck RegisterClassExA(&wc);
537c2c66affSColin Finck
538*7a62c32bSAmine Khaldi for(i = 0; i < ARRAY_SIZE(style); i++)
539c2c66affSColin Finck {
540c2c66affSColin Finck /* need not to destroy these windows due creation abort */
541c2c66affSColin Finck CreateWindowExA(0, cls_name, NULL, style[i],
542c2c66affSColin Finck 100, 100, 100, 100, NULL, NULL, wc.hInstance, (LPVOID)TRUE);
543c2c66affSColin Finck CreateWindowExA(0, cls_name, NULL, style[i],
544c2c66affSColin Finck 100, 100, 100, 100, NULL, NULL, wc.hInstance, (LPVOID)FALSE);
545c2c66affSColin Finck }
546c2c66affSColin Finck UnregisterClassA(cls_name, wc.hInstance);
547c2c66affSColin Finck }
548c2c66affSColin Finck
test_SetScrollInfo(void)549c2c66affSColin Finck static void test_SetScrollInfo(void)
550c2c66affSColin Finck {
551c2c66affSColin Finck SCROLLINFO si;
552c2c66affSColin Finck HWND mainwnd;
553c2c66affSColin Finck BOOL ret;
554c2c66affSColin Finck
555c2c66affSColin Finck mainwnd = create_main_test_wnd();
556c2c66affSColin Finck
557c2c66affSColin Finck ret = IsWindowEnabled(hScroll);
558c2c66affSColin Finck ok(ret, "scroll bar disabled\n");
559c2c66affSColin Finck
560c2c66affSColin Finck EnableScrollBar(hScroll, SB_CTL, ESB_DISABLE_BOTH);
561c2c66affSColin Finck
562c2c66affSColin Finck ret = IsWindowEnabled(hScroll);
563c2c66affSColin Finck ok(!ret, "scroll bar enabled\n");
564c2c66affSColin Finck
565c2c66affSColin Finck memset(&si, 0, sizeof(si));
566c2c66affSColin Finck si.cbSize = sizeof(si);
567c2c66affSColin Finck si.fMask = 0xf;
568c2c66affSColin Finck ret = GetScrollInfo(hScroll, SB_CTL, &si);
569c2c66affSColin Finck ok(ret, "got %d\n", ret);
570c2c66affSColin Finck
571c2c66affSColin Finck /* SetScrollInfo */
572c2c66affSColin Finck memset(&si, 0, sizeof(si));
573c2c66affSColin Finck si.cbSize = sizeof(si);
574c2c66affSColin Finck ret = IsWindowEnabled(hScroll);
575c2c66affSColin Finck ok(!ret, "scroll bar enabled\n");
576c2c66affSColin Finck si.fMask = SIF_POS|SIF_RANGE|SIF_PAGE|SIF_DISABLENOSCROLL;
577c2c66affSColin Finck si.nMax = 100;
578c2c66affSColin Finck si.nMin = 10;
579c2c66affSColin Finck si.nPos = 0;
580c2c66affSColin Finck si.nPage = 100;
581c2c66affSColin Finck SetScrollInfo(hScroll, SB_CTL, &si, TRUE);
582c2c66affSColin Finck ret = IsWindowEnabled(hScroll);
583c2c66affSColin Finck ok(!ret, "scroll bar enabled\n");
584c2c66affSColin Finck
585c2c66affSColin Finck si.fMask = 0xf;
586c2c66affSColin Finck ret = GetScrollInfo(hScroll, SB_CTL, &si);
587c2c66affSColin Finck ok(ret, "got %d\n", ret);
588c2c66affSColin Finck
589c2c66affSColin Finck EnableScrollBar(hScroll, SB_CTL, ESB_ENABLE_BOTH);
590c2c66affSColin Finck ok(IsWindowEnabled(hScroll), "expected enabled scrollbar\n");
591c2c66affSColin Finck
592c2c66affSColin Finck si.fMask = SIF_POS|SIF_RANGE|SIF_PAGE|SIF_DISABLENOSCROLL;
593c2c66affSColin Finck si.nMax = 10;
594c2c66affSColin Finck si.nMin = 100;
595c2c66affSColin Finck si.nPos = 0;
596c2c66affSColin Finck si.nPage = 100;
597c2c66affSColin Finck SetScrollInfo(hScroll, SB_CTL, &si, TRUE);
598c2c66affSColin Finck ret = IsWindowEnabled(hScroll);
599c2c66affSColin Finck ok(ret, "scroll bar disabled\n");
600c2c66affSColin Finck
601c2c66affSColin Finck DestroyWindow(hScroll);
602c2c66affSColin Finck DestroyWindow(mainwnd);
603c2c66affSColin Finck }
604c2c66affSColin Finck
605*7a62c32bSAmine Khaldi static WNDPROC scrollbar_wndproc;
606*7a62c32bSAmine Khaldi
607*7a62c32bSAmine Khaldi static SCROLLINFO set_scrollinfo;
608*7a62c32bSAmine Khaldi
subclass_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)609*7a62c32bSAmine Khaldi static LRESULT CALLBACK subclass_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
610*7a62c32bSAmine Khaldi {
611*7a62c32bSAmine Khaldi if (msg == WM_CREATE && ((CREATESTRUCTA*)lparam)->lpCreateParams)
612*7a62c32bSAmine Khaldi return DefWindowProcA(hwnd, msg, wparam, lparam);
613*7a62c32bSAmine Khaldi
614*7a62c32bSAmine Khaldi if (msg == SBM_SETSCROLLINFO)
615*7a62c32bSAmine Khaldi set_scrollinfo = *(SCROLLINFO*)lparam;
616*7a62c32bSAmine Khaldi
617*7a62c32bSAmine Khaldi return CallWindowProcA(scrollbar_wndproc, hwnd, msg, wparam, lparam);
618*7a62c32bSAmine Khaldi }
619*7a62c32bSAmine Khaldi
test_subclass(void)620*7a62c32bSAmine Khaldi static void test_subclass(void)
621*7a62c32bSAmine Khaldi {
622*7a62c32bSAmine Khaldi SCROLLBARINFO scroll_info;
623*7a62c32bSAmine Khaldi WNDCLASSEXA class_info;
624*7a62c32bSAmine Khaldi WNDCLASSA wc;
625*7a62c32bSAmine Khaldi LRESULT res;
626*7a62c32bSAmine Khaldi HWND hwnd;
627*7a62c32bSAmine Khaldi BOOL r;
628*7a62c32bSAmine Khaldi
629*7a62c32bSAmine Khaldi r = GetClassInfoExA(GetModuleHandleA(NULL), "SCROLLBAR", &class_info);
630*7a62c32bSAmine Khaldi ok(r, "GetClassInfoEx failed: %u\n", GetLastError());
631*7a62c32bSAmine Khaldi scrollbar_wndproc = class_info.lpfnWndProc;
632*7a62c32bSAmine Khaldi
633*7a62c32bSAmine Khaldi memset(&wc, 0, sizeof(wc));
634*7a62c32bSAmine Khaldi wc.cbWndExtra = class_info.cbWndExtra + 3; /* more space than needed works */
635*7a62c32bSAmine Khaldi wc.hInstance = GetModuleHandleA(NULL);
636*7a62c32bSAmine Khaldi wc.lpszClassName = "MyTestSubclass";
637*7a62c32bSAmine Khaldi wc.lpfnWndProc = subclass_proc;
638*7a62c32bSAmine Khaldi r = RegisterClassA(&wc);
639*7a62c32bSAmine Khaldi ok(r, "RegisterClass failed: %u\n", GetLastError());
640*7a62c32bSAmine Khaldi
641*7a62c32bSAmine Khaldi hwnd = CreateWindowExA( 0, "MyTestSubclass", "Scroll", WS_OVERLAPPEDWINDOW,
642*7a62c32bSAmine Khaldi CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0 );
643*7a62c32bSAmine Khaldi ok(hwnd != NULL, "Failed to create window: %u\n", GetLastError());
644*7a62c32bSAmine Khaldi
645*7a62c32bSAmine Khaldi r = SetScrollRange(hwnd, SB_CTL, 0, 100, TRUE);
646*7a62c32bSAmine Khaldi ok(r, "SetScrollRange failed: %u\n", GetLastError());
647*7a62c32bSAmine Khaldi
648*7a62c32bSAmine Khaldi res = SetScrollPos(hwnd, SB_CTL, 2, FALSE);
649*7a62c32bSAmine Khaldi ok(!res, "SetScrollPos returned %lu\n", res);
650*7a62c32bSAmine Khaldi
651*7a62c32bSAmine Khaldi memset(&set_scrollinfo, 0xcc, sizeof(set_scrollinfo));
652*7a62c32bSAmine Khaldi res = SetScrollPos(hwnd, SB_CTL, 1, FALSE);
653*7a62c32bSAmine Khaldi ok(res == 2, "SetScrollPos returned %lu\n", res);
654*7a62c32bSAmine Khaldi ok(set_scrollinfo.cbSize == sizeof(SCROLLINFO), "cbSize = %u\n", set_scrollinfo.cbSize);
655*7a62c32bSAmine Khaldi todo_wine
656*7a62c32bSAmine Khaldi ok(set_scrollinfo.fMask == (0x1000 | SIF_POS), "fMask = %x\n", set_scrollinfo.fMask);
657*7a62c32bSAmine Khaldi ok(set_scrollinfo.nPos == 1, "nPos = %x\n", set_scrollinfo.nPos);
658*7a62c32bSAmine Khaldi
659*7a62c32bSAmine Khaldi memset(&scroll_info, 0xcc, sizeof(scroll_info));
660*7a62c32bSAmine Khaldi scroll_info.cbSize = sizeof(scroll_info);
661*7a62c32bSAmine Khaldi res = SendMessageA(hwnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)&scroll_info);
662*7a62c32bSAmine Khaldi ok(res == 1, "SBM_GETSCROLLBARINFO returned %lu\n", res);
663*7a62c32bSAmine Khaldi
664*7a62c32bSAmine Khaldi DestroyWindow(hwnd);
665*7a62c32bSAmine Khaldi
666*7a62c32bSAmine Khaldi /* if we skip calling wndproc for WM_CREATE, window is not considered a scrollbar */
667*7a62c32bSAmine Khaldi hwnd = CreateWindowExA( 0, "MyTestSubclass", "Scroll", WS_OVERLAPPEDWINDOW,
668*7a62c32bSAmine Khaldi CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), (void *)1 );
669*7a62c32bSAmine Khaldi ok(hwnd != NULL, "Failed to create window: %u\n", GetLastError());
670*7a62c32bSAmine Khaldi
671*7a62c32bSAmine Khaldi memset(&scroll_info, 0xcc, sizeof(scroll_info));
672*7a62c32bSAmine Khaldi scroll_info.cbSize = sizeof(scroll_info);
673*7a62c32bSAmine Khaldi res = SendMessageA(hwnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)&scroll_info);
674*7a62c32bSAmine Khaldi ok(!res, "SBM_GETSCROLLBARINFO returned %lu\n", res);
675*7a62c32bSAmine Khaldi
676*7a62c32bSAmine Khaldi DestroyWindow(hwnd);
677*7a62c32bSAmine Khaldi
678*7a62c32bSAmine Khaldi /* not enough space in extra data */
679*7a62c32bSAmine Khaldi wc.cbWndExtra = class_info.cbWndExtra - 1;
680*7a62c32bSAmine Khaldi wc.lpszClassName = "MyTestSubclass2";
681*7a62c32bSAmine Khaldi r = RegisterClassA(&wc);
682*7a62c32bSAmine Khaldi ok(r, "RegisterClass failed: %u\n", GetLastError());
683*7a62c32bSAmine Khaldi
684*7a62c32bSAmine Khaldi hwnd = CreateWindowExA( 0, "MyTestSubclass2", "Scroll", WS_OVERLAPPEDWINDOW,
685*7a62c32bSAmine Khaldi CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0 );
686*7a62c32bSAmine Khaldi ok(hwnd != NULL, "Failed to create window: %u\n", GetLastError());
687*7a62c32bSAmine Khaldi
688*7a62c32bSAmine Khaldi memset(&scroll_info, 0xcc, sizeof(scroll_info));
689*7a62c32bSAmine Khaldi scroll_info.cbSize = sizeof(scroll_info);
690*7a62c32bSAmine Khaldi res = SendMessageA(hwnd, SBM_GETSCROLLBARINFO, 0, (LPARAM)&scroll_info);
691*7a62c32bSAmine Khaldi ok(!res, "SBM_GETSCROLLBARINFO returned %lu\n", res);
692*7a62c32bSAmine Khaldi
693*7a62c32bSAmine Khaldi memset(&set_scrollinfo, 0xcc, sizeof(set_scrollinfo));
694*7a62c32bSAmine Khaldi res = SetScrollPos(hwnd, SB_CTL, 1, FALSE);
695*7a62c32bSAmine Khaldi ok(res == 0, "SetScrollPos returned %lu\n", res);
696*7a62c32bSAmine Khaldi ok(set_scrollinfo.cbSize == sizeof(SCROLLINFO), "cbSize = %u\n", set_scrollinfo.cbSize);
697*7a62c32bSAmine Khaldi todo_wine
698*7a62c32bSAmine Khaldi ok(set_scrollinfo.fMask == (0x1000 | SIF_POS), "fMask = %x\n", set_scrollinfo.fMask);
699*7a62c32bSAmine Khaldi ok(set_scrollinfo.nPos == 1, "nPos = %x\n", set_scrollinfo.nPos);
700*7a62c32bSAmine Khaldi
701*7a62c32bSAmine Khaldi DestroyWindow(hwnd);
702*7a62c32bSAmine Khaldi }
703*7a62c32bSAmine Khaldi
START_TEST(scroll)704c2c66affSColin Finck START_TEST ( scroll )
705c2c66affSColin Finck {
706c2c66affSColin Finck WNDCLASSA wc;
707c2c66affSColin Finck HMODULE hUxtheme;
708c2c66affSColin Finck BOOL (WINAPI * pIsThemeActive)(VOID);
709c2c66affSColin Finck
710c2c66affSColin Finck wc.style = CS_HREDRAW | CS_VREDRAW;
711c2c66affSColin Finck wc.cbClsExtra = 0;
712c2c66affSColin Finck wc.cbWndExtra = 0;
713c2c66affSColin Finck wc.hInstance = GetModuleHandleA(NULL);
714c2c66affSColin Finck wc.hIcon = NULL;
715c2c66affSColin Finck wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_IBEAM);
716c2c66affSColin Finck wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
717c2c66affSColin Finck wc.lpszMenuName = NULL;
718c2c66affSColin Finck wc.lpszClassName = "MyTestWnd";
719c2c66affSColin Finck wc.lpfnWndProc = MyWndProc;
720c2c66affSColin Finck RegisterClassA(&wc);
721c2c66affSColin Finck
722c2c66affSColin Finck test_EnableScrollBar();
723c2c66affSColin Finck test_SetScrollPos();
724c2c66affSColin Finck test_ShowScrollBar();
725c2c66affSColin Finck test_GetScrollBarInfo();
726c2c66affSColin Finck scrollbar_test_track();
727c2c66affSColin Finck test_SetScrollInfo();
728*7a62c32bSAmine Khaldi test_subclass();
729c2c66affSColin Finck
730c2c66affSColin Finck /* Some test results vary depending of theming being active or not */
731c2c66affSColin Finck hUxtheme = LoadLibraryA("uxtheme.dll");
732c2c66affSColin Finck if (hUxtheme)
733c2c66affSColin Finck {
734c2c66affSColin Finck pIsThemeActive = (void*)GetProcAddress(hUxtheme, "IsThemeActive");
735c2c66affSColin Finck if (pIsThemeActive)
736c2c66affSColin Finck bThemeActive = pIsThemeActive();
737c2c66affSColin Finck FreeLibrary(hUxtheme);
738c2c66affSColin Finck }
739c2c66affSColin Finck
740c2c66affSColin Finck scrollbar_test_default( 0);
741c2c66affSColin Finck scrollbar_test_default( WS_HSCROLL);
742c2c66affSColin Finck scrollbar_test_default( WS_VSCROLL);
743c2c66affSColin Finck scrollbar_test_default( WS_HSCROLL | WS_VSCROLL);
744c2c66affSColin Finck
745c2c66affSColin Finck scrollbar_test_init();
746c2c66affSColin Finck }
747