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
24 static BOOL bThemeActive
= FALSE
;
26 static LRESULT CALLBACK
MyWndProc( HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
33 hScroll
= CreateWindowA( "SCROLLBAR", "", WS_CHILD
| WS_VISIBLE
, 0, 0, 120, 100, hWnd
, (HMENU
)100, GetModuleHandleA(0), 0 );
46 return DefWindowProcA(hWnd
, msg
, wParam
, lParam
);
51 static HWND
create_main_test_wnd(void)
56 hMainWnd
= CreateWindowExA( 0, "MyTestWnd", "Scroll",
57 WS_OVERLAPPEDWINDOW
|WS_VSCROLL
|WS_HSCROLL
,
58 CW_USEDEFAULT
, CW_USEDEFAULT
, 100, 100, NULL
, NULL
, GetModuleHandleA(NULL
), 0 );
59 ok(hMainWnd
!= NULL
, "Failed to create parent window. Tests aborted.\n");
60 ok(hScroll
!= NULL
, "got NULL scroll bar handle\n");
65 static void scrollbar_test_track(void)
69 mainwnd
= create_main_test_wnd();
71 /* test that scrollbar tracking is terminated when
72 * the control loses mouse capture */
73 SendMessageA( hScroll
, WM_LBUTTONDOWN
, 0, MAKELPARAM( 1, 1));
74 /* a normal return from SendMessage */
75 /* not normal for instances such as closing the window */
76 ok( IsWindow( hScroll
), "Scrollbar has gone!\n");
78 DestroyWindow(hScroll
);
79 DestroyWindow(mainwnd
);
82 static void test_EnableScrollBar(void)
87 mainwnd
= create_main_test_wnd();
89 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_DISABLE_BOTH
);
90 ok( ret
, "The scrollbar should be disabled.\n" );
91 ok( !IsWindowEnabled( hScroll
), "The scrollbar window should be disabled.\n" );
93 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_ENABLE_BOTH
);
94 ok( ret
, "The scrollbar should be enabled.\n" );
95 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be enabled.\n" );
97 /* test buttons separately */
98 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_DISABLE_LTUP
);
99 ok( ret
, "The scrollbar LTUP button should be disabled.\n" );
100 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be enabled.\n" );
101 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_ENABLE_BOTH
);
102 ok( ret
, "The scrollbar should be enabled.\n" );
103 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be enabled.\n" );
105 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_DISABLE_RTDN
);
106 ok( ret
, "The scrollbar RTDN button should be disabled.\n" );
107 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be enabled.\n" );
108 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_ENABLE_BOTH
);
109 ok( ret
, "The scrollbar should be enabled.\n" );
110 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be enabled.\n" );
112 /* disable window, try to re-enable */
113 ret
= EnableWindow( hScroll
, FALSE
);
114 ok( !ret
, "got %d\n", ret
);
115 ok( !IsWindowEnabled( hScroll
), "The scrollbar window should be disabled.\n" );
117 ret
= EnableScrollBar( hScroll
, SB_CTL
, ESB_ENABLE_BOTH
);
118 ok( ret
, "got %d\n", ret
);
119 ok( IsWindowEnabled( hScroll
), "The scrollbar window should be disabled.\n" );
121 DestroyWindow(hScroll
);
122 DestroyWindow(mainwnd
);
125 static void test_SetScrollPos(void)
130 mainwnd
= create_main_test_wnd();
132 EnableWindow( hScroll
, FALSE
);
133 ok( !IsWindowEnabled( hScroll
), "The scroll should be disabled.\n" );
135 ret
= SetScrollPos( hScroll
, SB_CTL
, 30, TRUE
);
136 ok( !ret
, "The position should not be set.\n" );
138 ret
= GetScrollPos( hScroll
, SB_CTL
);
139 ok( !ret
, "The position should be equal to zero\n");
141 ret
= SetScrollRange( hScroll
, SB_CTL
, 0, 100, TRUE
);
142 ok( ret
, "The range should be set.\n" );
144 ret
= SetScrollPos( hScroll
, SB_CTL
, 30, TRUE
);
145 ok( !ret
, "The position should not be set.\n" );
147 ret
= GetScrollPos( hScroll
, SB_CTL
);
148 ok( ret
== 30, "The position should be set!!!\n");
150 EnableWindow( hScroll
, TRUE
);
151 ok( IsWindowEnabled( hScroll
), "The scroll should be enabled.\n" );
153 ret
= SetScrollPos( hScroll
, SB_CTL
, 30, TRUE
);
154 ok( ret
== 30, "The position should be set.\n" );
156 ret
= GetScrollPos( hScroll
, SB_CTL
);
157 ok( ret
== 30, "The position should not be equal to zero\n");
159 ret
= SetScrollRange( hScroll
, SB_CTL
, 0, 100, TRUE
);
160 ok( ret
, "The range should be set.\n" );
162 ret
= SetScrollPos( hScroll
, SB_CTL
, 30, TRUE
);
163 ok( ret
== 30, "The position should be set.\n" );
165 ret
= GetScrollPos( hScroll
, SB_CTL
);
166 ok( ret
== 30, "The position should not be equal to zero\n");
168 DestroyWindow(hScroll
);
169 DestroyWindow(mainwnd
);
172 static void test_ShowScrollBar(void)
177 mainwnd
= create_main_test_wnd();
179 ret
= ShowScrollBar( hScroll
, SB_CTL
, FALSE
);
180 ok( ret
, "The ShowScrollBar() should not failed.\n" );
181 ok( !IsWindowVisible( hScroll
), "The scrollbar window should not be visible\n" );
183 ret
= ShowScrollBar( hScroll
, SB_CTL
, TRUE
);
184 ok( ret
, "The ShowScrollBar() should not failed.\n" );
185 ok( !IsWindowVisible( hScroll
), "The scrollbar window should be visible\n" );
187 ret
= ShowScrollBar( NULL
, SB_CTL
, TRUE
);
188 ok( !ret
, "The ShowScrollBar() should failed.\n" );
190 DestroyWindow(hScroll
);
191 DestroyWindow(mainwnd
);
194 static void test_GetScrollBarInfo(void)
200 BOOL (WINAPI
*pGetScrollBarInfo
)(HWND
, LONG
, LPSCROLLBARINFO
);
202 pGetScrollBarInfo
= (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetScrollBarInfo");
203 if (!pGetScrollBarInfo
)
205 win_skip("GetScrollBarInfo is not available\n");
209 hMainWnd
= create_main_test_wnd();
211 /* Test GetScrollBarInfo to make sure it returns rcScrollBar in screen
213 sbi
.cbSize
= sizeof(sbi
);
214 ret
= pGetScrollBarInfo( hScroll
, OBJID_CLIENT
, &sbi
);
215 ok( ret
, "The GetScrollBarInfo() call should not fail.\n" );
216 GetWindowRect( hScroll
, &rect
);
217 ok( ret
, "The GetWindowRect() call should not fail.\n" );
218 ok( !(sbi
.rgstate
[0] & (STATE_SYSTEM_INVISIBLE
|STATE_SYSTEM_OFFSCREEN
)),
219 "unexpected rgstate(0x%x)\n", sbi
.rgstate
[0]);
220 ok(EqualRect(&rect
, &sbi
.rcScrollBar
), "WindowRect %s != rcScrollBar %s\n",
221 wine_dbgstr_rect(&rect
), wine_dbgstr_rect(&sbi
.rcScrollBar
));
223 /* Test windows horizontal and vertical scrollbar to make sure rcScrollBar
224 * is still returned in screen coordinates by moving the window, and
225 * making sure that it shifts the rcScrollBar value. */
226 ShowWindow( hMainWnd
, SW_SHOW
);
227 sbi
.cbSize
= sizeof(sbi
);
228 ret
= pGetScrollBarInfo( hMainWnd
, OBJID_HSCROLL
, &sbi
);
229 ok( ret
, "The GetScrollBarInfo() call should not fail.\n" );
230 GetWindowRect( hMainWnd
, &rect
);
231 ok( ret
, "The GetWindowRect() call should not fail.\n" );
232 MoveWindow( hMainWnd
, rect
.left
+5, rect
.top
+5,
233 rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
234 rect
= sbi
.rcScrollBar
;
235 OffsetRect(&rect
, 5, 5);
236 ret
= pGetScrollBarInfo( hMainWnd
, OBJID_HSCROLL
, &sbi
);
237 ok( ret
, "The GetScrollBarInfo() call should not fail.\n" );
238 ok(EqualRect(&rect
, &sbi
.rcScrollBar
), "PreviousRect %s != CurrentRect %s\n",
239 wine_dbgstr_rect(&rect
), wine_dbgstr_rect(&sbi
.rcScrollBar
));
241 sbi
.cbSize
= sizeof(sbi
);
242 ret
= pGetScrollBarInfo( hMainWnd
, OBJID_VSCROLL
, &sbi
);
243 ok( ret
, "The GetScrollBarInfo() call should not fail.\n" );
244 GetWindowRect( hMainWnd
, &rect
);
245 ok( ret
, "The GetWindowRect() call should not fail.\n" );
246 MoveWindow( hMainWnd
, rect
.left
+5, rect
.top
+5,
247 rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
248 rect
= sbi
.rcScrollBar
;
249 OffsetRect(&rect
, 5, 5);
250 ret
= pGetScrollBarInfo( hMainWnd
, OBJID_VSCROLL
, &sbi
);
251 ok( ret
, "The GetScrollBarInfo() call should not fail.\n" );
252 ok(EqualRect(&rect
, &sbi
.rcScrollBar
), "PreviousRect %s != CurrentRect %s\n",
253 wine_dbgstr_rect(&rect
), wine_dbgstr_rect(&sbi
.rcScrollBar
));
255 DestroyWindow(hScroll
);
256 DestroyWindow(hMainWnd
);
259 /* some tests designed to show that Horizontal and Vertical
260 * window scroll bar info are not created independently */
261 static void scrollbar_test_default( DWORD style
)
266 SCROLLINFO si
= { sizeof( SCROLLINFO
), SIF_TRACKPOS
};
268 hwnd
= CreateWindowExA( 0, "static", "", WS_POPUP
| style
,
269 0, 0, 10, 10, 0, 0, 0, NULL
);
272 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
274 broken( !ret
) /* Win 9x/ME */ , "GetScrollRange failed.\n");
275 /* range is 0,0 if there are no H or V scroll bars. 0,100 otherwise */
276 if( !( style
& ( WS_VSCROLL
| WS_HSCROLL
)))
277 ok( min
== 0 && max
== 0,
278 "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min
, max
, style
);
280 ok(( min
== 0 && max
== 100) ||
281 broken( min
== 0 && max
== 0), /* Win 9x/ME */
282 "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min
, max
, style
);
283 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
285 broken( !ret
) /* Win 9x/ME */ , "GetScrollRange failed.\n");
286 /* range is 0,0 if there are no H or V scroll bars. 0,100 otherwise */
287 if( !( style
& ( WS_VSCROLL
| WS_HSCROLL
)))
288 ok( min
== 0 && max
== 0,
289 "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min
, max
, style
);
291 ok(( min
== 0 && max
== 100) ||
292 broken( min
== 0 && max
== 0), /* Win 9x/ME */
293 "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min
, max
, style
);
294 /* test GetScrollInfo, vist for vertical SB */
295 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
296 /* should fail if no H or V scroll bar styles are present. Succeed otherwise */
297 if( !( style
& ( WS_VSCROLL
| WS_HSCROLL
)))
298 ok( !ret
, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style
);
301 broken( !ret
), /* Win 9x/ME */
302 "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
303 /* Same for Horizontal SB */
304 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
305 /* should fail if no H or V scroll bar styles are present. Succeed otherwise */
306 if( !( style
& ( WS_VSCROLL
| WS_HSCROLL
)))
307 ok( !ret
, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style
);
310 broken( !ret
), /* Win 9x/ME */
311 "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
312 /* now set the Vertical Scroll range to something that could be the default value it
314 ret
= SetScrollRange( hwnd
, SB_VERT
, 0, 100, FALSE
);
315 ok( ret
, "SetScrollRange failed.\n");
316 /* and request the Horizontal range */
317 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
318 ok( ret
, "GetScrollRange failed.\n");
319 /* now the range should be 0,100 in ALL cases */
320 ok( min
== 0 && max
== 100,
321 "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min
, max
, style
);
322 /* See what is different now for GetScrollRange */
323 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
324 /* should succeed in ALL cases */
325 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
326 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
327 /* should succeed in ALL cases */
328 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
329 /* report the windows style */
330 winstyle
= GetWindowLongA( hwnd
, GWL_STYLE
);
331 /* WS_VSCROLL added to the window style */
332 if( !(style
& WS_VSCROLL
))
334 if (bThemeActive
|| style
!= WS_HSCROLL
)
336 ok( (winstyle
& (WS_HSCROLL
|WS_VSCROLL
)) == ( style
| WS_VSCROLL
),
337 "unexpected style change %08x/%08x\n", winstyle
, style
);
339 ok( (winstyle
& (WS_HSCROLL
|WS_VSCROLL
)) == style
,
340 "unexpected style change %08x/%08x\n", winstyle
, style
);
342 /* do the test again with H and V reversed.
343 * Start with a clean window */
344 DestroyWindow( hwnd
);
345 hwnd
= CreateWindowExA( 0, "static", "", WS_POPUP
| style
,
346 0, 0, 10, 10, 0, 0, 0, NULL
);
348 /* Set Horizontal Scroll range to something that could be the default value it
350 ret
= SetScrollRange( hwnd
, SB_HORZ
, 0, 100, FALSE
);
351 ok( ret
, "SetScrollRange failed.\n");
352 /* and request the Vertical range */
353 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
354 ok( ret
, "GetScrollRange failed.\n");
355 /* now the range should be 0,100 in ALL cases */
356 ok( min
== 0 && max
== 100,
357 "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min
, max
, style
);
358 /* See what is different now for GetScrollRange */
359 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
360 /* should succeed in ALL cases */
361 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
362 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
363 /* should succeed in ALL cases */
364 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
365 /* report the windows style */
366 winstyle
= GetWindowLongA( hwnd
, GWL_STYLE
);
367 /* WS_HSCROLL added to the window style */
368 if( !(style
& WS_HSCROLL
))
370 if (bThemeActive
|| style
!= WS_VSCROLL
)
372 ok( (winstyle
& (WS_HSCROLL
|WS_VSCROLL
)) == ( style
| WS_HSCROLL
),
373 "unexpected style change %08x/%08x\n", winstyle
, style
);
375 ok( (winstyle
& (WS_HSCROLL
|WS_VSCROLL
)) == style
,
376 "unexpected style change %08x/%08x\n", winstyle
, style
);
378 /* Slightly change the test to use SetScrollInfo
379 * Start with a clean window */
380 DestroyWindow( hwnd
);
381 hwnd
= CreateWindowExA( 0, "static", "", WS_POPUP
| style
,
382 0, 0, 10, 10, 0, 0, 0, NULL
);
384 /* set Horizontal position with SetScrollInfo */
388 si
.fMask
|= SIF_RANGE
;
389 ret
= SetScrollInfo( hwnd
, SB_HORZ
, &si
, FALSE
);
390 ok( ret
, "SetScrollInfo failed. Style is %08x\n", style
);
391 /* and request the Vertical range */
392 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
393 ok( ret
, "GetScrollRange failed.\n");
394 /* now the range should be 0,100 in ALL cases */
395 ok( min
== 0 && max
== 100,
396 "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min
, max
, style
);
397 /* See what is different now for GetScrollRange */
398 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
399 /* should succeed in ALL cases */
400 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
401 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
402 /* should succeed in ALL cases */
403 ok( ret
, "GetScrollInfo failed unexpectedly. Style is %08x\n", style
);
404 /* also test if the window scroll bars are enabled */
405 ret
= EnableScrollBar( hwnd
, SB_VERT
, ESB_ENABLE_BOTH
);
406 ok( !ret
, "Vertical window scroll bar was not enabled\n");
407 ret
= EnableScrollBar( hwnd
, SB_HORZ
, ESB_ENABLE_BOTH
);
408 ok( !ret
, "Horizontal window scroll bar was not enabled\n");
409 DestroyWindow( hwnd
);
410 /* finally, check if adding a WS_[HV]SCROLL style of a window makes the scroll info
412 if( style
& (WS_HSCROLL
| WS_VSCROLL
)) return;/* only test if not yet set */
413 /* Start with a clean window */
414 DestroyWindow( hwnd
);
415 hwnd
= CreateWindowExA( 0, "static", "", WS_POPUP
,
416 0, 0, 10, 10, 0, 0, 0, NULL
);
418 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
420 ok( !ret
, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style
);
421 /* add scroll styles */
422 winstyle
= GetWindowLongA( hwnd
, GWL_STYLE
);
423 SetWindowLongW( hwnd
, GWL_STYLE
, winstyle
| WS_VSCROLL
| WS_HSCROLL
);
424 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
425 /* should still fail */
426 ok( !ret
, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style
);
428 DestroyWindow( hwnd
);
431 static LRESULT CALLBACK
scroll_init_proc(HWND hwnd
, UINT msg
,
432 WPARAM wparam
, LPARAM lparam
)
434 SCROLLINFO horz
, vert
;
435 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
441 return cs
->lpCreateParams
? DefWindowProcA(hwnd
, msg
, wparam
, lparam
) :
445 horz
.cbSize
= sizeof horz
;
446 horz
.fMask
= SIF_ALL
;
447 horz
.nMin
= 0xdeadbeaf;
448 horz
.nMax
= 0xbaadc0de;
450 h_ret
= GetScrollInfo(hwnd
, SB_HORZ
, &horz
);
451 v_ret
= GetScrollInfo(hwnd
, SB_VERT
, &vert
);
453 if(cs
->lpCreateParams
)
455 /* WM_NCCREATE was passed to DefWindowProc */
456 if(cs
->style
& (WS_VSCROLL
| WS_HSCROLL
))
458 ok(h_ret
&& v_ret
, "GetScrollInfo() should return NON-zero "
459 "but got h_ret=%d v_ret=%d\n", h_ret
, v_ret
);
460 ok(vert
.nMin
== 0 && vert
.nMax
== 100,
461 "unexpected init values(SB_VERT): min=%d max=%d\n",
462 vert
.nMin
, vert
.nMax
);
463 ok(horz
.nMin
== 0 && horz
.nMax
== 100,
464 "unexpected init values(SB_HORZ): min=%d max=%d\n",
465 horz
.nMin
, horz
.nMax
);
469 ok(!h_ret
&& !v_ret
, "GetScrollInfo() should return zeru, "
470 "but got h_ret=%d v_ret=%d\n", h_ret
, v_ret
);
471 ok(vert
.nMin
== 0xdeadbeaf && vert
.nMax
== 0xbaadc0de,
472 "unexpected initialization(SB_VERT): min=%d max=%d\n",
473 vert
.nMin
, vert
.nMax
);
474 ok(horz
.nMin
== 0xdeadbeaf && horz
.nMax
== 0xbaadc0de,
475 "unexpected initialization(SB_HORZ): min=%d max=%d\n",
476 horz
.nMin
, horz
.nMax
);
481 ok(!h_ret
&& !v_ret
, "GetScrollInfo() should return zeru, "
482 "but got h_ret=%d v_ret=%d\n", h_ret
, v_ret
);
483 ok(horz
.nMin
== 0xdeadbeaf && horz
.nMax
== 0xbaadc0de &&
484 vert
.nMin
== 0xdeadbeaf && vert
.nMax
== 0xbaadc0de,
485 "unexpected initialization\n");
487 return FALSE
; /* abort creation */
490 /* need for WM_GETMINMAXINFO, which precedes WM_NCCREATE */
495 static void scrollbar_test_init(void)
498 CHAR cls_name
[] = "scroll_test_class";
499 LONG style
[] = {WS_VSCROLL
, WS_HSCROLL
, WS_VSCROLL
| WS_HSCROLL
, 0};
502 memset( &wc
, 0, sizeof wc
);
503 wc
.cbSize
= sizeof wc
;
504 wc
.style
= CS_VREDRAW
| CS_HREDRAW
;
505 wc
.hInstance
= GetModuleHandleA(0);
506 wc
.hCursor
= LoadCursorA(NULL
, (LPCSTR
)IDC_ARROW
);
507 wc
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
508 wc
.lpszClassName
= cls_name
;
509 wc
.lpfnWndProc
= scroll_init_proc
;
510 RegisterClassExA(&wc
);
512 for(i
= 0; i
< sizeof style
/ sizeof style
[0]; i
++)
514 /* need not to destroy these windows due creation abort */
515 CreateWindowExA(0, cls_name
, NULL
, style
[i
],
516 100, 100, 100, 100, NULL
, NULL
, wc
.hInstance
, (LPVOID
)TRUE
);
517 CreateWindowExA(0, cls_name
, NULL
, style
[i
],
518 100, 100, 100, 100, NULL
, NULL
, wc
.hInstance
, (LPVOID
)FALSE
);
520 UnregisterClassA(cls_name
, wc
.hInstance
);
523 static void test_SetScrollInfo(void)
529 mainwnd
= create_main_test_wnd();
531 ret
= IsWindowEnabled(hScroll
);
532 ok(ret
, "scroll bar disabled\n");
534 EnableScrollBar(hScroll
, SB_CTL
, ESB_DISABLE_BOTH
);
536 ret
= IsWindowEnabled(hScroll
);
537 ok(!ret
, "scroll bar enabled\n");
539 memset(&si
, 0, sizeof(si
));
540 si
.cbSize
= sizeof(si
);
542 ret
= GetScrollInfo(hScroll
, SB_CTL
, &si
);
543 ok(ret
, "got %d\n", ret
);
546 memset(&si
, 0, sizeof(si
));
547 si
.cbSize
= sizeof(si
);
548 ret
= IsWindowEnabled(hScroll
);
549 ok(!ret
, "scroll bar enabled\n");
550 si
.fMask
= SIF_POS
|SIF_RANGE
|SIF_PAGE
|SIF_DISABLENOSCROLL
;
555 SetScrollInfo(hScroll
, SB_CTL
, &si
, TRUE
);
556 ret
= IsWindowEnabled(hScroll
);
557 ok(!ret
, "scroll bar enabled\n");
560 ret
= GetScrollInfo(hScroll
, SB_CTL
, &si
);
561 ok(ret
, "got %d\n", ret
);
563 EnableScrollBar(hScroll
, SB_CTL
, ESB_ENABLE_BOTH
);
564 ok(IsWindowEnabled(hScroll
), "expected enabled scrollbar\n");
566 si
.fMask
= SIF_POS
|SIF_RANGE
|SIF_PAGE
|SIF_DISABLENOSCROLL
;
571 SetScrollInfo(hScroll
, SB_CTL
, &si
, TRUE
);
572 ret
= IsWindowEnabled(hScroll
);
573 ok(ret
, "scroll bar disabled\n");
575 DestroyWindow(hScroll
);
576 DestroyWindow(mainwnd
);
579 START_TEST ( scroll
)
583 BOOL (WINAPI
* pIsThemeActive
)(VOID
);
585 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
588 wc
.hInstance
= GetModuleHandleA(NULL
);
590 wc
.hCursor
= LoadCursorA(NULL
, (LPCSTR
)IDC_IBEAM
);
591 wc
.hbrBackground
= GetSysColorBrush(COLOR_WINDOW
);
592 wc
.lpszMenuName
= NULL
;
593 wc
.lpszClassName
= "MyTestWnd";
594 wc
.lpfnWndProc
= MyWndProc
;
597 test_EnableScrollBar();
599 test_ShowScrollBar();
600 test_GetScrollBarInfo();
601 scrollbar_test_track();
602 test_SetScrollInfo();
604 /* Some test results vary depending of theming being active or not */
605 hUxtheme
= LoadLibraryA("uxtheme.dll");
608 pIsThemeActive
= (void*)GetProcAddress(hUxtheme
, "IsThemeActive");
610 bThemeActive
= pIsThemeActive();
611 FreeLibrary(hUxtheme
);
614 scrollbar_test_default( 0);
615 scrollbar_test_default( WS_HSCROLL
);
616 scrollbar_test_default( WS_VSCROLL
);
617 scrollbar_test_default( WS_HSCROLL
| WS_VSCROLL
);
619 scrollbar_test_init();