691855b01c3f1c3c1fcaa8a2e29b63ad2b3decf3
2 * Unit tests for scrollbar
4 * Copyright 2008 Lyutin Anatoly (Etersoft)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/test.h"
29 static BOOL bThemeActive
= FALSE
;
31 static LRESULT CALLBACK
MyWndProc( HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
38 hScroll
= CreateWindowA( "SCROLLBAR", "", WS_CHILD
| WS_VISIBLE
, 0, 0, 120, 100, hWnd
, (HMENU
)100, GetModuleHandleA(0), 0 );
51 return DefWindowProcA(hWnd
, msg
, wParam
, lParam
);
56 static HWND
create_main_test_wnd(void)
61 hMainWnd
= CreateWindowExA( 0, "MyTestWnd", "Scroll",
62 WS_OVERLAPPEDWINDOW
|WS_VSCROLL
|WS_HSCROLL
,
63 CW_USEDEFAULT
, CW_USEDEFAULT
, 100, 100, NULL
, NULL
, GetModuleHandleA(NULL
), 0 );
64 ok(hMainWnd
!= NULL
, "Failed to create parent window. Tests aborted.\n");
65 ok(hScroll
!= NULL
, "got NULL scroll bar handle\n");
70 static void scrollbar_test_track(void)
74 mainwnd
= create_main_test_wnd();
76 /* test that scrollbar tracking is terminated when
77 * the control loses mouse capture */
78 SendMessageA( hScroll
, WM_LBUTTONDOWN
, 0, MAKELPARAM( 1, 1));
79 /* a normal return from SendMessage */
80 /* not normal for instances such as closing the window */
81 ok( IsWindow( hScroll
), "Scrollbar has gone!\n");
83 DestroyWindow(hScroll
);
84 DestroyWindow(mainwnd
);
87 static void test_EnableScrollBar(void)
92 mainwnd
= create_main_test_wnd();
94 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_DISABLE_BOTH
);
95 ok( ret
, "The scrollbar should be disabled.\n" );
96 ok( !IsWindowEnabled( hScroll
), "The scrollbar window should be disabled.\n" );
98 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_ENABLE_BOTH
);
99 ok( ret
, "The scrollbar should be enabled.\n" );
100 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be enabled.\n" );
102 /* test buttons separately */
103 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_DISABLE_LTUP
);
104 ok( ret
, "The scrollbar LTUP button should be disabled.\n" );
105 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be enabled.\n" );
106 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_ENABLE_BOTH
);
107 ok( ret
, "The scrollbar should be enabled.\n" );
108 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be enabled.\n" );
110 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_DISABLE_RTDN
);
111 ok( ret
, "The scrollbar RTDN button should be disabled.\n" );
112 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be enabled.\n" );
113 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_ENABLE_BOTH
);
114 ok( ret
, "The scrollbar should be enabled.\n" );
115 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be enabled.\n" );
117 DestroyWindow(hScroll
);
118 DestroyWindow(mainwnd
);
121 static void test_SetScrollPos(void)
126 mainwnd
= create_main_test_wnd();
128 EnableWindow( hScroll
, FALSE
);
129 ok( !IsWindowEnabled( hScroll
), "The scroll should be disabled.\n" );
131 ret
= SetScrollPos( hScroll
, SB_CTL
, 30, TRUE
);
132 ok( !ret
, "The position should not be set.\n" );
134 ret
= GetScrollPos( hScroll
, SB_CTL
);
135 ok( !ret
, "The position should be equal to zero\n");
137 ret
= SetScrollRange( hScroll
, SB_CTL
, 0, 100, TRUE
);
138 ok( ret
, "The range should be set.\n" );
140 ret
= SetScrollPos( hScroll
, SB_CTL
, 30, TRUE
);
141 ok( !ret
, "The position should not be set.\n" );
143 ret
= GetScrollPos( hScroll
, SB_CTL
);
144 ok( ret
== 30, "The position should be set!!!\n");
146 EnableWindow( hScroll
, TRUE
);
147 ok( IsWindowEnabled( hScroll
), "The scroll should be enabled.\n" );
149 ret
= SetScrollPos( hScroll
, SB_CTL
, 30, TRUE
);
150 ok( ret
== 30, "The position should be set.\n" );
152 ret
= GetScrollPos( hScroll
, SB_CTL
);
153 ok( ret
== 30, "The position should not be equal to zero\n");
155 ret
= SetScrollRange( hScroll
, SB_CTL
, 0, 100, TRUE
);
156 ok( ret
, "The range should be set.\n" );
158 ret
= SetScrollPos( hScroll
, SB_CTL
, 30, TRUE
);
159 ok( ret
== 30, "The position should be set.\n" );
161 ret
= GetScrollPos( hScroll
, SB_CTL
);
162 ok( ret
== 30, "The position should not be equal to zero\n");
164 DestroyWindow(hScroll
);
165 DestroyWindow(mainwnd
);
168 static void test_ShowScrollBar(void)
173 mainwnd
= create_main_test_wnd();
175 ret
= ShowScrollBar( hScroll
, SB_CTL
, FALSE
);
176 ok( ret
, "The ShowScrollBar() should not failed.\n" );
177 ok( !IsWindowVisible( hScroll
), "The scrollbar window should not be visible\n" );
179 ret
= ShowScrollBar( hScroll
, SB_CTL
, TRUE
);
180 ok( ret
, "The ShowScrollBar() should not failed.\n" );
181 ok( !IsWindowVisible( hScroll
), "The scrollbar window should be visible\n" );
183 ret
= ShowScrollBar( NULL
, SB_CTL
, TRUE
);
184 ok( !ret
, "The ShowScrollBar() should failed.\n" );
186 DestroyWindow(hScroll
);
187 DestroyWindow(mainwnd
);
190 static void test_GetScrollBarInfo(void)
196 BOOL (WINAPI
*pGetScrollBarInfo
)(HWND
, LONG
, LPSCROLLBARINFO
);
198 pGetScrollBarInfo
= (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetScrollBarInfo");
199 if (!pGetScrollBarInfo
)
201 win_skip("GetScrollBarInfo is not available\n");
205 hMainWnd
= create_main_test_wnd();
207 /* Test GetScrollBarInfo to make sure it returns rcScrollBar in screen
209 sbi
.cbSize
= sizeof(sbi
);
210 ret
= pGetScrollBarInfo( hScroll
, OBJID_CLIENT
, &sbi
);
211 ok( ret
, "The GetScrollBarInfo() call should not fail.\n" );
212 GetWindowRect( hScroll
, &rect
);
213 ok( ret
, "The GetWindowRect() call should not fail.\n" );
214 ok( !(sbi
.rgstate
[0] & (STATE_SYSTEM_INVISIBLE
|STATE_SYSTEM_OFFSCREEN
)),
215 "unexpected rgstate(0x%x)\n", sbi
.rgstate
[0]);
216 ok( EqualRect(&rect
, &sbi
.rcScrollBar
),
217 "WindowRect(%d, %d, %d, %d) != rcScrollBar(%d, %d, %d, %d)\n",
218 rect
.top
, rect
.left
, rect
.bottom
, rect
.right
,
219 sbi
.rcScrollBar
.top
, sbi
.rcScrollBar
.left
,
220 sbi
.rcScrollBar
.bottom
, sbi
.rcScrollBar
.right
);
222 /* Test windows horizontal and vertical scrollbar to make sure rcScrollBar
223 * is still returned in screen coordinates by moving the window, and
224 * making sure that it shifts the rcScrollBar value. */
225 ShowWindow( hMainWnd
, SW_SHOW
);
226 sbi
.cbSize
= sizeof(sbi
);
227 ret
= pGetScrollBarInfo( hMainWnd
, OBJID_HSCROLL
, &sbi
);
228 ok( ret
, "The GetScrollBarInfo() call should not fail.\n" );
229 GetWindowRect( hMainWnd
, &rect
);
230 ok( ret
, "The GetWindowRect() call should not fail.\n" );
231 MoveWindow( hMainWnd
, rect
.left
+5, rect
.top
+5,
232 rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
233 rect
= sbi
.rcScrollBar
;
234 OffsetRect(&rect
, 5, 5);
235 ret
= pGetScrollBarInfo( hMainWnd
, OBJID_HSCROLL
, &sbi
);
236 ok( ret
, "The GetScrollBarInfo() call should not fail.\n" );
237 ok( EqualRect(&rect
, &sbi
.rcScrollBar
),
238 "PreviousRect(%d, %d, %d, %d) != CurrentRect(%d, %d, %d, %d)\n",
239 rect
.top
, rect
.left
, rect
.bottom
, rect
.right
,
240 sbi
.rcScrollBar
.top
, sbi
.rcScrollBar
.left
,
241 sbi
.rcScrollBar
.bottom
, sbi
.rcScrollBar
.right
);
243 sbi
.cbSize
= sizeof(sbi
);
244 ret
= pGetScrollBarInfo( hMainWnd
, OBJID_VSCROLL
, &sbi
);
245 ok( ret
, "The GetScrollBarInfo() call should not fail.\n" );
246 GetWindowRect( hMainWnd
, &rect
);
247 ok( ret
, "The GetWindowRect() call should not fail.\n" );
248 MoveWindow( hMainWnd
, rect
.left
+5, rect
.top
+5,
249 rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
250 rect
= sbi
.rcScrollBar
;
251 OffsetRect(&rect
, 5, 5);
252 ret
= pGetScrollBarInfo( hMainWnd
, OBJID_VSCROLL
, &sbi
);
253 ok( ret
, "The GetScrollBarInfo() call should not fail.\n" );
254 ok( EqualRect(&rect
, &sbi
.rcScrollBar
),
255 "PreviousRect(%d, %d, %d, %d) != CurrentRect(%d, %d, %d, %d)\n",
256 rect
.top
, rect
.left
, rect
.bottom
, rect
.right
,
257 sbi
.rcScrollBar
.top
, sbi
.rcScrollBar
.left
,
258 sbi
.rcScrollBar
.bottom
, sbi
.rcScrollBar
.right
);
260 DestroyWindow(hScroll
);
261 DestroyWindow(hMainWnd
);
264 /* some tests designed to show that Horizontal and Vertical
265 * window scroll bar info are not created independently */
266 static void scrollbar_test_default( DWORD style
)
271 SCROLLINFO si
= { sizeof( SCROLLINFO
), SIF_TRACKPOS
};
273 hwnd
= CreateWindowExA( 0, "static", "", WS_POPUP
| style
,
274 0, 0, 10, 10, 0, 0, 0, NULL
);
277 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
279 broken( !ret
) /* Win 9x/ME */ , "GetScrollRange failed.\n");
280 /* range is 0,0 if there are no H or V scroll bars. 0,100 otherwise */
281 if( !( style
& ( WS_VSCROLL
| WS_HSCROLL
)))
282 ok( min
== 0 && max
== 0,
283 "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min
, max
, style
);
285 ok(( min
== 0 && max
== 100) ||
286 broken( min
== 0 && max
== 0), /* Win 9x/ME */
287 "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min
, max
, style
);
288 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
290 broken( !ret
) /* Win 9x/ME */ , "GetScrollRange failed.\n");
291 /* range is 0,0 if there are no H or V scroll bars. 0,100 otherwise */
292 if( !( style
& ( WS_VSCROLL
| WS_HSCROLL
)))
293 ok( min
== 0 && max
== 0,
294 "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min
, max
, style
);
296 ok(( min
== 0 && max
== 100) ||
297 broken( min
== 0 && max
== 0), /* Win 9x/ME */
298 "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min
, max
, style
);
299 /* test GetScrollInfo, vist for vertical SB */
300 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
301 /* should fail if no H or V scroll bar styles are present. Succeed otherwise */
302 if( !( style
& ( WS_VSCROLL
| WS_HSCROLL
)))
303 ok( !ret
, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style
);
306 broken( !ret
), /* Win 9x/ME */
307 "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
308 /* Same for Horizontal SB */
309 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
310 /* should fail if no H or V scroll bar styles are present. Succeed otherwise */
311 if( !( style
& ( WS_VSCROLL
| WS_HSCROLL
)))
312 ok( !ret
, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style
);
315 broken( !ret
), /* Win 9x/ME */
316 "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
317 /* now set the Vertical Scroll range to something that could be the default value it
319 ret
= SetScrollRange( hwnd
, SB_VERT
, 0, 100, FALSE
);
320 ok( ret
, "SetScrollRange failed.\n");
321 /* and request the Horizontal range */
322 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
323 ok( ret
, "GetScrollRange failed.\n");
324 /* now the range should be 0,100 in ALL cases */
325 ok( min
== 0 && max
== 100,
326 "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min
, max
, style
);
327 /* See what is different now for GetScrollRange */
328 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
329 /* should succeed in ALL cases */
330 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
331 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
332 /* should succeed in ALL cases */
333 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
334 /* report the windows style */
335 winstyle
= GetWindowLongA( hwnd
, GWL_STYLE
);
336 /* WS_VSCROLL added to the window style */
337 if( !(style
& WS_VSCROLL
))
339 if (bThemeActive
|| style
!= WS_HSCROLL
)
341 ok( (winstyle
& (WS_HSCROLL
|WS_VSCROLL
)) == ( style
| WS_VSCROLL
),
342 "unexpected style change %08x/%08x\n", winstyle
, style
);
344 ok( (winstyle
& (WS_HSCROLL
|WS_VSCROLL
)) == style
,
345 "unexpected style change %08x/%08x\n", winstyle
, style
);
347 /* do the test again with H and V reversed.
348 * Start with a clean window */
349 DestroyWindow( hwnd
);
350 hwnd
= CreateWindowExA( 0, "static", "", WS_POPUP
| style
,
351 0, 0, 10, 10, 0, 0, 0, NULL
);
353 /* Set Horizontal Scroll range to something that could be the default value it
355 ret
= SetScrollRange( hwnd
, SB_HORZ
, 0, 100, FALSE
);
356 ok( ret
, "SetScrollRange failed.\n");
357 /* and request the Vertical range */
358 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
359 ok( ret
, "GetScrollRange failed.\n");
360 /* now the range should be 0,100 in ALL cases */
361 ok( min
== 0 && max
== 100,
362 "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min
, max
, style
);
363 /* See what is different now for GetScrollRange */
364 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
365 /* should succeed in ALL cases */
366 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
367 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
368 /* should succeed in ALL cases */
369 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
370 /* report the windows style */
371 winstyle
= GetWindowLongA( hwnd
, GWL_STYLE
);
372 /* WS_HSCROLL added to the window style */
373 if( !(style
& WS_HSCROLL
))
375 if (bThemeActive
|| style
!= WS_VSCROLL
)
377 ok( (winstyle
& (WS_HSCROLL
|WS_VSCROLL
)) == ( style
| WS_HSCROLL
),
378 "unexpected style change %08x/%08x\n", winstyle
, style
);
380 ok( (winstyle
& (WS_HSCROLL
|WS_VSCROLL
)) == style
,
381 "unexpected style change %08x/%08x\n", winstyle
, style
);
383 /* Slightly change the test to use SetScrollInfo
384 * Start with a clean window */
385 DestroyWindow( hwnd
);
386 hwnd
= CreateWindowExA( 0, "static", "", WS_POPUP
| style
,
387 0, 0, 10, 10, 0, 0, 0, NULL
);
389 /* set Horizontal position with SetScrollInfo */
393 si
.fMask
|= SIF_RANGE
;
394 ret
= SetScrollInfo( hwnd
, SB_HORZ
, &si
, FALSE
);
395 ok( ret
, "SetScrollInfo failed. Style is %08x\n", style
);
396 /* and request the Vertical range */
397 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
398 ok( ret
, "GetScrollRange failed.\n");
399 /* now the range should be 0,100 in ALL cases */
400 ok( min
== 0 && max
== 100,
401 "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min
, max
, style
);
402 /* See what is different now for GetScrollRange */
403 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
404 /* should succeed in ALL cases */
405 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
406 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
407 /* should succeed in ALL cases */
408 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
409 /* also test if the window scroll bars are enabled */
410 ret
= EnableScrollBar( hwnd
, SB_VERT
, ESB_ENABLE_BOTH
);
411 ok( !ret
, "Vertical window scroll bar was not enabled\n");
412 ret
= EnableScrollBar( hwnd
, SB_HORZ
, ESB_ENABLE_BOTH
);
413 ok( !ret
, "Horizontal window scroll bar was not enabled\n");
414 DestroyWindow( hwnd
);
415 /* finally, check if adding a WS_[HV]SCROLL style of a window makes the scroll info
417 if( style
& (WS_HSCROLL
| WS_VSCROLL
)) return;/* only test if not yet set */
418 /* Start with a clean window */
419 DestroyWindow( hwnd
);
420 hwnd
= CreateWindowExA( 0, "static", "", WS_POPUP
,
421 0, 0, 10, 10, 0, 0, 0, NULL
);
423 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
425 ok( !ret
, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style
);
426 /* add scroll styles */
427 winstyle
= GetWindowLongA( hwnd
, GWL_STYLE
);
428 SetWindowLongW( hwnd
, GWL_STYLE
, winstyle
| WS_VSCROLL
| WS_HSCROLL
);
429 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
430 /* should still fail */
431 ok( !ret
, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style
);
433 DestroyWindow( hwnd
);
436 static LRESULT CALLBACK
scroll_init_proc(HWND hwnd
, UINT msg
,
437 WPARAM wparam
, LPARAM lparam
)
439 SCROLLINFO horz
, vert
;
440 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
446 return cs
->lpCreateParams
? DefWindowProcA(hwnd
, msg
, wparam
, lparam
) :
450 horz
.cbSize
= sizeof horz
;
451 horz
.fMask
= SIF_ALL
;
452 horz
.nMin
= 0xdeadbeaf;
453 horz
.nMax
= 0xbaadc0de;
455 h_ret
= GetScrollInfo(hwnd
, SB_HORZ
, &horz
);
456 v_ret
= GetScrollInfo(hwnd
, SB_VERT
, &vert
);
458 if(cs
->lpCreateParams
)
460 /* WM_NCCREATE was passed to DefWindowProc */
461 if(cs
->style
& (WS_VSCROLL
| WS_HSCROLL
))
463 ok(h_ret
&& v_ret
, "GetScrollInfo() should return NON-zero "
464 "but got h_ret=%d v_ret=%d\n", h_ret
, v_ret
);
465 ok(vert
.nMin
== 0 && vert
.nMax
== 100,
466 "unexpected init values(SB_VERT): min=%d max=%d\n",
467 vert
.nMin
, vert
.nMax
);
468 ok(horz
.nMin
== 0 && horz
.nMax
== 100,
469 "unexpected init values(SB_HORZ): min=%d max=%d\n",
470 horz
.nMin
, horz
.nMax
);
474 ok(!h_ret
&& !v_ret
, "GetScrollInfo() should return zeru, "
475 "but got h_ret=%d v_ret=%d\n", h_ret
, v_ret
);
476 ok(vert
.nMin
== 0xdeadbeaf && vert
.nMax
== 0xbaadc0de,
477 "unexpected initialization(SB_VERT): min=%d max=%d\n",
478 vert
.nMin
, vert
.nMax
);
479 ok(horz
.nMin
== 0xdeadbeaf && horz
.nMax
== 0xbaadc0de,
480 "unexpected initialization(SB_HORZ): min=%d max=%d\n",
481 horz
.nMin
, horz
.nMax
);
486 ok(!h_ret
&& !v_ret
, "GetScrollInfo() should return zeru, "
487 "but got h_ret=%d v_ret=%d\n", h_ret
, v_ret
);
488 ok(horz
.nMin
== 0xdeadbeaf && horz
.nMax
== 0xbaadc0de &&
489 vert
.nMin
== 0xdeadbeaf && vert
.nMax
== 0xbaadc0de,
490 "unexpected initialization\n");
492 return FALSE
; /* abort creation */
495 /* need for WM_GETMINMAXINFO, which precedes WM_NCCREATE */
500 static void scrollbar_test_init(void)
503 CHAR cls_name
[] = "scroll_test_class";
504 LONG style
[] = {WS_VSCROLL
, WS_HSCROLL
, WS_VSCROLL
| WS_HSCROLL
, 0};
507 memset( &wc
, 0, sizeof wc
);
508 wc
.cbSize
= sizeof wc
;
509 wc
.style
= CS_VREDRAW
| CS_HREDRAW
;
510 wc
.hInstance
= GetModuleHandleA(0);
511 wc
.hCursor
= LoadCursorA(NULL
, (LPCSTR
)IDC_ARROW
);
512 wc
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
513 wc
.lpszClassName
= cls_name
;
514 wc
.lpfnWndProc
= scroll_init_proc
;
515 RegisterClassExA(&wc
);
517 for(i
= 0; i
< sizeof style
/ sizeof style
[0]; i
++)
519 /* need not to destroy these windows due creation abort */
520 CreateWindowExA(0, cls_name
, NULL
, style
[i
],
521 100, 100, 100, 100, NULL
, NULL
, wc
.hInstance
, (LPVOID
)TRUE
);
522 CreateWindowExA(0, cls_name
, NULL
, style
[i
],
523 100, 100, 100, 100, NULL
, NULL
, wc
.hInstance
, (LPVOID
)FALSE
);
525 UnregisterClassA(cls_name
, wc
.hInstance
);
528 static void test_SetScrollInfo(void)
534 mainwnd
= create_main_test_wnd();
536 ret
= IsWindowEnabled(hScroll
);
537 ok(ret
, "scroll bar disabled\n");
539 EnableScrollBar(hScroll
, SB_CTL
, ESB_DISABLE_BOTH
);
541 ret
= IsWindowEnabled(hScroll
);
542 ok(!ret
, "scroll bar disabled\n");
544 memset(&si
, 0, sizeof(si
));
545 si
.cbSize
= sizeof(si
);
547 ret
= GetScrollInfo(hScroll
, SB_CTL
, &si
);
548 ok(ret
, "got %d\n", ret
);
551 memset(&si
, 0, sizeof(si
));
552 si
.cbSize
= sizeof(si
);
553 ret
= IsWindowEnabled(hScroll
);
554 ok(!ret
, "scroll bar disabled\n");
555 si
.fMask
= SIF_POS
|SIF_RANGE
|SIF_PAGE
|SIF_DISABLENOSCROLL
;
559 SetScrollInfo(hScroll
, SB_CTL
, &si
, TRUE
);
560 ret
= IsWindowEnabled(hScroll
);
561 ok(!ret
, "scroll bar enabled\n");
564 ret
= GetScrollInfo(hScroll
, SB_CTL
, &si
);
565 ok(ret
, "got %d\n", ret
);
567 DestroyWindow(hScroll
);
568 DestroyWindow(mainwnd
);
571 START_TEST ( scroll
)
575 BOOL (WINAPI
* pIsThemeActive
)(VOID
);
577 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
580 wc
.hInstance
= GetModuleHandleA(NULL
);
582 wc
.hCursor
= LoadCursorA(NULL
, (LPCSTR
)IDC_IBEAM
);
583 wc
.hbrBackground
= GetSysColorBrush(COLOR_WINDOW
);
584 wc
.lpszMenuName
= NULL
;
585 wc
.lpszClassName
= "MyTestWnd";
586 wc
.lpfnWndProc
= MyWndProc
;
589 test_EnableScrollBar();
591 test_ShowScrollBar();
592 test_GetScrollBarInfo();
593 scrollbar_test_track();
594 test_SetScrollInfo();
596 /* Some test results vary depending of theming being active or not */
597 hUxtheme
= LoadLibraryA("uxtheme.dll");
600 pIsThemeActive
= (void*)GetProcAddress(hUxtheme
, "IsThemeActive");
602 bThemeActive
= pIsThemeActive();
603 FreeLibrary(hUxtheme
);
606 scrollbar_test_default( 0);
607 scrollbar_test_default( WS_HSCROLL
);
608 scrollbar_test_default( WS_VSCROLL
);
609 scrollbar_test_default( WS_HSCROLL
| WS_VSCROLL
);
611 scrollbar_test_init();