ReactOS  0.4.13-dev-651-g5dbc677
scroll.c File Reference
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <windows.h>
#include "wine/test.h"
Include dependency graph for scroll.c:

Go to the source code of this file.

Functions

static LRESULT CALLBACK MyWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static HWND create_main_test_wnd (void)
 
static void scrollbar_test_track (void)
 
static void test_EnableScrollBar (void)
 
static void test_SetScrollPos (void)
 
static void test_ShowScrollBar (void)
 
static void test_GetScrollBarInfo (void)
 
static void scrollbar_test_default (DWORD style)
 
static LRESULT CALLBACK scroll_init_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void scrollbar_test_init (void)
 
static void test_SetScrollInfo (void)
 
 START_TEST (scroll)
 

Variables

static HWND hScroll
 
static BOOL bThemeActive = FALSE
 

Function Documentation

◆ create_main_test_wnd()

static HWND create_main_test_wnd ( void  )
static

Definition at line 56 of file scroll.c.

57 {
58  HWND hMainWnd;
59 
60  hScroll = NULL;
61  hMainWnd = CreateWindowExA( 0, "MyTestWnd", "Scroll",
64  ok(hMainWnd != NULL, "Failed to create parent window. Tests aborted.\n");
65  ok(hScroll != NULL, "got NULL scroll bar handle\n");
66 
67  return hMainWnd;
68 }
#define ok(value,...)
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
static HWND hScroll
Definition: scroll.c:28
#define WS_HSCROLL
Definition: pedump.c:628
HWND hMainWnd
Definition: magnifier.c:32
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
#define WS_VSCROLL
Definition: pedump.c:627
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637

Referenced by scrollbar_test_track(), test_EnableScrollBar(), test_GetScrollBarInfo(), test_SetScrollInfo(), test_SetScrollPos(), and test_ShowScrollBar().

◆ MyWndProc()

static LRESULT CALLBACK MyWndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 31 of file scroll.c.

32 {
33  switch(msg)
34  {
35 
36  case WM_CREATE:
37  {
38  hScroll = CreateWindowA( "SCROLLBAR", "", WS_CHILD | WS_VISIBLE, 0, 0, 120, 100, hWnd, (HMENU)100, GetModuleHandleA(0), 0 );
39 
40  return 0;
41  }
42  case WM_DESTROY:
43  PostQuitMessage(0);
44  break;
45  case WM_HSCROLL:
46  case WM_VSCROLL:
47  /* stop tracking */
49  return 0;
50  default:
51  return DefWindowProcA(hWnd, msg, wParam, lParam);
52  }
53  return 0;
54 }
HWND hWnd
Definition: settings.c:17
#define WS_CHILD
Definition: pedump.c:617
WPARAM wParam
Definition: combotst.c:138
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4216
#define WM_DESTROY
Definition: winuser.h:1591
static HWND hScroll
Definition: scroll.c:28
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_HSCROLL
Definition: winuser.h:1725
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
#define WM_CREATE
Definition: winuser.h:1590
#define WS_VISIBLE
Definition: pedump.c:620
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_VSCROLL
Definition: winuser.h:1726

Referenced by START_TEST().

◆ scroll_init_proc()

static LRESULT CALLBACK scroll_init_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 436 of file scroll.c.

438 {
439  SCROLLINFO horz, vert;
441  BOOL h_ret, v_ret;
442 
443  switch(msg)
444  {
445  case WM_NCCREATE:
446  return cs->lpCreateParams ? DefWindowProcA(hwnd, msg, wparam, lparam) :
447  TRUE;
448 
449  case WM_CREATE:
450  horz.cbSize = sizeof horz;
451  horz.fMask = SIF_ALL;
452  horz.nMin = 0xdeadbeaf;
453  horz.nMax = 0xbaadc0de;
454  vert = horz;
455  h_ret = GetScrollInfo(hwnd, SB_HORZ, &horz);
456  v_ret = GetScrollInfo(hwnd, SB_VERT, &vert);
457 
458  if(cs->lpCreateParams)
459  {
460  /* WM_NCCREATE was passed to DefWindowProc */
461  if(cs->style & (WS_VSCROLL | WS_HSCROLL))
462  {
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);
471  }
472  else
473  {
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);
482  }
483  }
484  else
485  {
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");
491  }
492  return FALSE; /* abort creation */
493 
494  default:
495  /* need for WM_GETMINMAXINFO, which precedes WM_NCCREATE */
496  return 0;
497  }
498 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
#define WM_NCCREATE
Definition: winuser.h:1665
uint32_t cs
Definition: isohybrid.c:75
unsigned int BOOL
Definition: ntddk_ex.h:94
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define ok(value,...)
#define WS_HSCROLL
Definition: pedump.c:628
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WS_VSCROLL
Definition: pedump.c:627
#define msg(x)
Definition: auth_time.c:54
#define WM_CREATE
Definition: winuser.h:1590
static UINT WPARAM wparam
Definition: combo.c:716
#define SIF_ALL
Definition: winuser.h:1218

Referenced by scrollbar_test_init().

◆ scrollbar_test_default()

static void scrollbar_test_default ( DWORD  style)
static

Definition at line 266 of file scroll.c.

267 {
268  INT min, max, ret;
269  DWORD winstyle;
270  HWND hwnd;
271  SCROLLINFO si = { sizeof( SCROLLINFO), SIF_TRACKPOS };
272 
273  hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style,
274  0, 0, 10, 10, 0, 0, 0, NULL);
275  assert( hwnd != 0);
276 
278  ok( ret ||
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);
284  else
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);
289  ok( ret ||
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);
295  else
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);
304  else
305  ok( ret ||
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);
313  else
314  ok( ret ||
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
318  * already has */;
319  ret = SetScrollRange( hwnd, SB_VERT, 0, 100, FALSE);
320  ok( ret, "SetScrollRange failed.\n");
321  /* and request the Horizontal range */
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))
338  {
339  if (bThemeActive || style != WS_HSCROLL)
340 todo_wine
341  ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == ( style | WS_VSCROLL),
342  "unexpected style change %08x/%08x\n", winstyle, style);
343  else
344  ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == style,
345  "unexpected style change %08x/%08x\n", winstyle, style);
346  }
347  /* do the test again with H and V reversed.
348  * Start with a clean window */
350  hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style,
351  0, 0, 10, 10, 0, 0, 0, NULL);
352  assert( hwnd != 0);
353  /* Set Horizontal Scroll range to something that could be the default value it
354  * already has */;
355  ret = SetScrollRange( hwnd, SB_HORZ, 0, 100, FALSE);
356  ok( ret, "SetScrollRange failed.\n");
357  /* and request the Vertical range */
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))
374  {
375  if (bThemeActive || style != WS_VSCROLL)
376 todo_wine
377  ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == ( style | WS_HSCROLL),
378  "unexpected style change %08x/%08x\n", winstyle, style);
379  else
380  ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == style,
381  "unexpected style change %08x/%08x\n", winstyle, style);
382  }
383  /* Slightly change the test to use SetScrollInfo
384  * Start with a clean window */
386  hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style,
387  0, 0, 10, 10, 0, 0, 0, NULL);
388  assert( hwnd != 0);
389  /* set Horizontal position with SetScrollInfo */
390  si.nPos = 0;
391  si.nMin = 11;
392  si.nMax = 22;
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 */
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 */
411  ok( !ret, "Vertical window scroll bar was not enabled\n");
413  ok( !ret, "Horizontal window scroll bar was not enabled\n");
415  /* finally, check if adding a WS_[HV]SCROLL style of a window makes the scroll info
416  * available */
417  if( style & (WS_HSCROLL | WS_VSCROLL)) return;/* only test if not yet set */
418  /* Start with a clean window */
420  hwnd = CreateWindowExA( 0, "static", "", WS_POPUP ,
421  0, 0, 10, 10, 0, 0, 0, NULL);
422  assert( hwnd != 0);
423  ret = GetScrollInfo( hwnd, SB_VERT, &si);
424  /* should fail */
425  ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style);
426  /* add scroll styles */
427  winstyle = GetWindowLongA( hwnd, GWL_STYLE );
429  ret = GetScrollInfo( hwnd, SB_VERT, &si);
430  /* should still fail */
431  ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style);
432  /* clean up */
434 }
BOOL WINAPI GetScrollRange(_In_ HWND, _In_ int, _Out_ LPINT, _Out_ LPINT)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define max(a, b)
Definition: svc.c:63
#define SIF_RANGE
Definition: winuser.h:1221
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
#define assert(x)
Definition: debug.h:53
BOOL WINAPI DestroyWindow(_In_ HWND)
int32_t INT
Definition: typedefs.h:56
LONG WINAPI GetWindowLongA(_In_ HWND, _In_ int)
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
struct tagSCROLLINFO SCROLLINFO
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WS_HSCROLL
Definition: pedump.c:628
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
int ret
#define todo_wine
Definition: test.h:154
#define broken(x)
Definition: _sntprintf.h:21
#define GWL_STYLE
Definition: winuser.h:846
#define SIF_TRACKPOS
Definition: winuser.h:1223
#define min(a, b)
Definition: monoChain.cc:55
#define WS_POPUP
Definition: pedump.c:616
#define WS_VSCROLL
Definition: pedump.c:627
BOOL WINAPI SetScrollRange(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ BOOL)
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
BOOL WINAPI EnableScrollBar(_In_ HWND, _In_ UINT, _In_ UINT)
Arabic default style
Definition: afstyles.h:93
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define ESB_ENABLE_BOTH
Definition: winuser.h:563
static BOOL bThemeActive
Definition: scroll.c:29

Referenced by START_TEST().

◆ scrollbar_test_init()

static void scrollbar_test_init ( void  )
static

Definition at line 500 of file scroll.c.

501 {
502  WNDCLASSEXA wc;
503  CHAR cls_name[] = "scroll_test_class";
505  int i;
506 
507  memset( &wc, 0, sizeof wc );
508  wc.cbSize = sizeof wc;
509  wc.style = CS_VREDRAW | CS_HREDRAW;
510  wc.hInstance = GetModuleHandleA(0);
513  wc.lpszClassName = cls_name;
515  RegisterClassExA(&wc);
516 
517  for(i = 0; i < sizeof style / sizeof style[0]; i++)
518  {
519  /* need not to destroy these windows due creation abort */
521  100, 100, 100, 100, NULL, NULL, wc.hInstance, (LPVOID)TRUE);
523  100, 100, 100, 100, NULL, NULL, wc.hInstance, (LPVOID)FALSE);
524  }
526 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
UINT style
Definition: winuser.h:3176
#define TRUE
Definition: types.h:120
HCURSOR hCursor
Definition: winuser.h:3182
WNDPROC lpfnWndProc
Definition: winuser.h:3177
LPCSTR lpszClassName
Definition: winuser.h:3185
char CHAR
Definition: xmlstorage.h:175
#define CS_HREDRAW
Definition: winuser.h:648
#define WHITE_BRUSH
Definition: wingdi.h:901
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HINSTANCE hInstance
Definition: winuser.h:3180
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
UINT cbSize
Definition: winuser.h:3175
const char * LPCSTR
Definition: xmlstorage.h:183
HBRUSH hbrBackground
Definition: winuser.h:3183
#define CS_VREDRAW
Definition: winuser.h:653
#define WS_HSCROLL
Definition: pedump.c:628
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
static LRESULT CALLBACK scroll_init_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: scroll.c:436
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
#define WS_VSCROLL
Definition: pedump.c:627
#define IDC_ARROW
Definition: winuser.h:682
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
static const char cls_name[]
Definition: compobj.c:2470
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
Arabic default style
Definition: afstyles.h:93
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ scrollbar_test_track()

static void scrollbar_test_track ( void  )
static

Definition at line 70 of file scroll.c.

71 {
72  HWND mainwnd;
73 
74  mainwnd = create_main_test_wnd();
75 
76  /* test that scrollbar tracking is terminated when
77  * the control loses mouse capture */
79  /* a normal return from SendMessage */
80  /* not normal for instances such as closing the window */
81  ok( IsWindow( hScroll), "Scrollbar has gone!\n");
82 
84  DestroyWindow(mainwnd);
85 }
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
BOOL WINAPI IsWindow(_In_opt_ HWND)
static HWND create_main_test_wnd(void)
Definition: scroll.c:56
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MAKELPARAM(l, h)
Definition: winuser.h:3947
BOOL WINAPI DestroyWindow(_In_ HWND)
#define ok(value,...)
static HWND hScroll
Definition: scroll.c:28

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( scroll  )

Definition at line 584 of file scroll.c.

585 {
586  WNDCLASSA wc;
587  HMODULE hUxtheme;
589 
590  wc.style = CS_HREDRAW | CS_VREDRAW;
591  wc.cbClsExtra = 0;
592  wc.cbWndExtra = 0;
594  wc.hIcon = NULL;
597  wc.lpszMenuName = NULL;
598  wc.lpszClassName = "MyTestWnd";
599  wc.lpfnWndProc = MyWndProc;
600  RegisterClassA(&wc);
601 
608 
609  /* Some test results vary depending of theming being active or not */
610  hUxtheme = LoadLibraryA("uxtheme.dll");
611  if (hUxtheme)
612  {
613  pIsThemeActive = (void*)GetProcAddress(hUxtheme, "IsThemeActive");
614  if (pIsThemeActive)
616  FreeLibrary(hUxtheme);
617  }
618 
623 
625 }
static void test_ShowScrollBar(void)
Definition: scroll.c:177
static void test_GetScrollBarInfo(void)
Definition: scroll.c:199
int cbClsExtra
Definition: winuser.h:3139
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3145
HBRUSH hbrBackground
Definition: winuser.h:3144
#define BOOL
Definition: nt_native.h:43
#define COLOR_WINDOW
Definition: winuser.h:908
#define IDC_IBEAM
Definition: winuser.h:683
int cbWndExtra
Definition: winuser.h:3140
static void scrollbar_test_track(void)
Definition: scroll.c:70
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
HCURSOR hCursor
Definition: winuser.h:3143
static IsThemeActiveT pIsThemeActive
Definition: treelist.c:367
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
static void scrollbar_test_init(void)
Definition: scroll.c:500
static void test_SetScrollPos(void)
Definition: scroll.c:130
#define CS_VREDRAW
Definition: winuser.h:653
#define FreeLibrary(x)
Definition: compat.h:405
static void test_EnableScrollBar(void)
Definition: scroll.c:87
static void scrollbar_test_default(DWORD style)
Definition: scroll.c:266
#define WINAPI
Definition: msvc.h:8
#define WS_HSCROLL
Definition: pedump.c:628
#define VOID
Definition: acefi.h:82
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
LPCSTR lpszClassName
Definition: winuser.h:3146
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
UINT style
Definition: winuser.h:3137
HINSTANCE hInstance
Definition: winuser.h:3141
#define WS_VSCROLL
Definition: pedump.c:627
WNDPROC lpfnWndProc
Definition: winuser.h:3138
static void test_SetScrollInfo(void)
Definition: scroll.c:528
#define GetProcAddress(x, y)
Definition: compat.h:410
static LRESULT CALLBACK MyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: scroll.c:31
HBRUSH WINAPI GetSysColorBrush(_In_ int)
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
static BOOL bThemeActive
Definition: scroll.c:29
HICON hIcon
Definition: winuser.h:3142

◆ test_EnableScrollBar()

static void test_EnableScrollBar ( void  )
static

Definition at line 87 of file scroll.c.

88 {
89  HWND mainwnd;
90  BOOL ret;
91 
92  mainwnd = create_main_test_wnd();
93 
95  ok( ret, "The scrollbar should be disabled.\n" );
96  ok( !IsWindowEnabled( hScroll ), "The scrollbar window should be disabled.\n" );
97 
99  ok( ret, "The scrollbar should be enabled.\n" );
100  ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" );
101 
102  /* test buttons separately */
104  ok( ret, "The scrollbar LTUP button should be disabled.\n" );
105  ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" );
107  ok( ret, "The scrollbar should be enabled.\n" );
108  ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" );
109 
111  ok( ret, "The scrollbar RTDN button should be disabled.\n" );
112  ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" );
114  ok( ret, "The scrollbar should be enabled.\n" );
115  ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" );
116 
117  /* disable window, try to re-enable */
119  ok( !ret, "got %d\n", ret );
120  ok( !IsWindowEnabled( hScroll ), "The scrollbar window should be disabled.\n" );
121 
123  ok( ret, "got %d\n", ret );
124  ok( IsWindowEnabled( hScroll ), "The scrollbar window should be disabled.\n" );
125 
127  DestroyWindow(mainwnd);
128 }
#define SB_CTL
Definition: winuser.h:554
#define ESB_DISABLE_BOTH
Definition: winuser.h:556
#define ESB_DISABLE_RTDN
Definition: winuser.h:561
static HWND create_main_test_wnd(void)
Definition: scroll.c:56
BOOL WINAPI DestroyWindow(_In_ HWND)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define ESB_DISABLE_LTUP
Definition: winuser.h:559
static HWND hScroll
Definition: scroll.c:28
int ret
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
BOOL WINAPI EnableScrollBar(_In_ HWND, _In_ UINT, _In_ UINT)
#define ESB_ENABLE_BOTH
Definition: winuser.h:563

Referenced by START_TEST().

◆ test_GetScrollBarInfo()

static void test_GetScrollBarInfo ( void  )
static

Definition at line 199 of file scroll.c.

200 {
201  HWND hMainWnd;
202  BOOL ret;
203  SCROLLBARINFO sbi;
204  RECT rect;
205  BOOL (WINAPI *pGetScrollBarInfo)(HWND, LONG, LPSCROLLBARINFO);
206 
207  pGetScrollBarInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetScrollBarInfo");
208  if (!pGetScrollBarInfo)
209  {
210  win_skip("GetScrollBarInfo is not available\n");
211  return;
212  }
213 
215 
216  /* Test GetScrollBarInfo to make sure it returns rcScrollBar in screen
217  * coordinates. */
218  sbi.cbSize = sizeof(sbi);
219  ret = pGetScrollBarInfo( hScroll, OBJID_CLIENT, &sbi);
220  ok( ret, "The GetScrollBarInfo() call should not fail.\n" );
222  ok( ret, "The GetWindowRect() call should not fail.\n" );
224  "unexpected rgstate(0x%x)\n", sbi.rgstate[0]);
225  ok(EqualRect(&rect, &sbi.rcScrollBar), "WindowRect %s != rcScrollBar %s\n",
227 
228  /* Test windows horizontal and vertical scrollbar to make sure rcScrollBar
229  * is still returned in screen coordinates by moving the window, and
230  * making sure that it shifts the rcScrollBar value. */
232  sbi.cbSize = sizeof(sbi);
233  ret = pGetScrollBarInfo( hMainWnd, OBJID_HSCROLL, &sbi);
234  ok( ret, "The GetScrollBarInfo() call should not fail.\n" );
236  ok( ret, "The GetWindowRect() call should not fail.\n" );
237  MoveWindow( hMainWnd, rect.left+5, rect.top+5,
238  rect.right-rect.left, rect.bottom-rect.top, TRUE );
239  rect = sbi.rcScrollBar;
240  OffsetRect(&rect, 5, 5);
241  ret = pGetScrollBarInfo( hMainWnd, OBJID_HSCROLL, &sbi);
242  ok( ret, "The GetScrollBarInfo() call should not fail.\n" );
243  ok(EqualRect(&rect, &sbi.rcScrollBar), "PreviousRect %s != CurrentRect %s\n",
245 
246  sbi.cbSize = sizeof(sbi);
247  ret = pGetScrollBarInfo( hMainWnd, OBJID_VSCROLL, &sbi);
248  ok( ret, "The GetScrollBarInfo() call should not fail.\n" );
250  ok( ret, "The GetWindowRect() call should not fail.\n" );
251  MoveWindow( hMainWnd, rect.left+5, rect.top+5,
252  rect.right-rect.left, rect.bottom-rect.top, TRUE );
253  rect = sbi.rcScrollBar;
254  OffsetRect(&rect, 5, 5);
255  ret = pGetScrollBarInfo( hMainWnd, OBJID_VSCROLL, &sbi);
256  ok( ret, "The GetScrollBarInfo() call should not fail.\n" );
257  ok(EqualRect(&rect, &sbi.rcScrollBar), "PreviousRect %s != CurrentRect %s\n",
259 
262 }
#define TRUE
Definition: types.h:120
#define STATE_SYSTEM_OFFSCREEN
Definition: winuser.h:2852
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
static HWND create_main_test_wnd(void)
Definition: scroll.c:56
HANDLE HWND
Definition: compat.h:13
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define BOOL
Definition: nt_native.h:43
BOOL WINAPI DestroyWindow(_In_ HWND)
& rect
Definition: startmenu.cpp:1413
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define ok(value,...)
#define SW_SHOW
Definition: winuser.h:769
DWORD rgstate[CCHILDREN_SCROLLBAR+1]
Definition: winuser.h:3728
#define OBJID_CLIENT
Definition: winable.h:19
#define OBJID_HSCROLL
Definition: winable.h:21
struct tagSCROLLBARINFO * LPSCROLLBARINFO
#define WINAPI
Definition: msvc.h:8
const char * wine_dbgstr_rect(const RECT *rect)
static HWND hScroll
Definition: scroll.c:28
#define OBJID_VSCROLL
Definition: winable.h:20
int ret
HWND hMainWnd
Definition: magnifier.c:32
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
#define GetProcAddress(x, y)
Definition: compat.h:410
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define win_skip
Definition: test.h:141
#define STATE_SYSTEM_INVISIBLE
Definition: winuser.h:2851

Referenced by START_TEST().

◆ test_SetScrollInfo()

static void test_SetScrollInfo ( void  )
static

Definition at line 528 of file scroll.c.

529 {
530  SCROLLINFO si;
531  HWND mainwnd;
532  BOOL ret;
533 
534  mainwnd = create_main_test_wnd();
535 
537  ok(ret, "scroll bar disabled\n");
538 
540 
542  ok(!ret, "scroll bar enabled\n");
543 
544  memset(&si, 0, sizeof(si));
545  si.cbSize = sizeof(si);
546  si.fMask = 0xf;
547  ret = GetScrollInfo(hScroll, SB_CTL, &si);
548  ok(ret, "got %d\n", ret);
549 
550  /* SetScrollInfo */
551  memset(&si, 0, sizeof(si));
552  si.cbSize = sizeof(si);
554  ok(!ret, "scroll bar enabled\n");
556  si.nMax = 100;
557  si.nMin = 10;
558  si.nPos = 0;
559  si.nPage = 100;
562  ok(!ret, "scroll bar enabled\n");
563 
564  si.fMask = 0xf;
565  ret = GetScrollInfo(hScroll, SB_CTL, &si);
566  ok(ret, "got %d\n", ret);
567 
569  ok(IsWindowEnabled(hScroll), "expected enabled scrollbar\n");
570 
572  si.nMax = 10;
573  si.nMin = 100;
574  si.nPos = 0;
575  si.nPage = 100;
578  ok(ret, "scroll bar disabled\n");
579 
581  DestroyWindow(mainwnd);
582 }
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
#define SB_CTL
Definition: winuser.h:554
#define ESB_DISABLE_BOTH
Definition: winuser.h:556
static HWND create_main_test_wnd(void)
Definition: scroll.c:56
BOOL WINAPI DestroyWindow(_In_ HWND)
#define SIF_PAGE
Definition: winuser.h:1219
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
BOOL WINAPI IsWindowEnabled(_In_ HWND)
static HWND hScroll
Definition: scroll.c:28
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
int ret
#define SIF_POS
Definition: winuser.h:1220
#define SIF_DISABLENOSCROLL
Definition: winuser.h:1222
BOOL WINAPI EnableScrollBar(_In_ HWND, _In_ UINT, _In_ UINT)
#define memset(x, y, z)
Definition: compat.h:39
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define ESB_ENABLE_BOTH
Definition: winuser.h:563

Referenced by START_TEST().

◆ test_SetScrollPos()

static void test_SetScrollPos ( void  )
static

Definition at line 130 of file scroll.c.

131 {
132  HWND mainwnd;
133  int ret;
134 
135  mainwnd = create_main_test_wnd();
136 
138  ok( !IsWindowEnabled( hScroll ), "The scroll should be disabled.\n" );
139 
140  ret = SetScrollPos( hScroll, SB_CTL, 30, TRUE);
141  ok( !ret, "The position should not be set.\n" );
142 
144  ok( !ret, "The position should be equal to zero\n");
145 
146  ret = SetScrollRange( hScroll, SB_CTL, 0, 100, TRUE );
147  ok( ret, "The range should be set.\n" );
148 
149  ret = SetScrollPos( hScroll, SB_CTL, 30, TRUE);
150  ok( !ret , "The position should not be set.\n" );
151 
153  ok( ret == 30, "The position should be set!!!\n");
154 
156  ok( IsWindowEnabled( hScroll ), "The scroll should be enabled.\n" );
157 
158  ret = SetScrollPos( hScroll, SB_CTL, 30, TRUE);
159  ok( ret == 30, "The position should be set.\n" );
160 
162  ok( ret == 30, "The position should not be equal to zero\n");
163 
164  ret = SetScrollRange( hScroll, SB_CTL, 0, 100, TRUE );
165  ok( ret, "The range should be set.\n" );
166 
167  ret = SetScrollPos( hScroll, SB_CTL, 30, TRUE);
168  ok( ret == 30, "The position should be set.\n" );
169 
171  ok( ret == 30, "The position should not be equal to zero\n");
172 
174  DestroyWindow(mainwnd);
175 }
#define TRUE
Definition: types.h:120
#define SB_CTL
Definition: winuser.h:554
static HWND create_main_test_wnd(void)
Definition: scroll.c:56
BOOL WINAPI DestroyWindow(_In_ HWND)
#define ok(value,...)
BOOL WINAPI IsWindowEnabled(_In_ HWND)
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
static HWND hScroll
Definition: scroll.c:28
int ret
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
BOOL WINAPI SetScrollRange(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ BOOL)
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)

Referenced by START_TEST().

◆ test_ShowScrollBar()

static void test_ShowScrollBar ( void  )
static

Definition at line 177 of file scroll.c.

178 {
179  HWND mainwnd;
180  BOOL ret;
181 
182  mainwnd = create_main_test_wnd();
183 
185  ok( ret, "The ShowScrollBar() should not failed.\n" );
186  ok( !IsWindowVisible( hScroll ), "The scrollbar window should not be visible\n" );
187 
189  ok( ret, "The ShowScrollBar() should not failed.\n" );
190  ok( !IsWindowVisible( hScroll ), "The scrollbar window should be visible\n" );
191 
193  ok( !ret, "The ShowScrollBar() should failed.\n" );
194 
196  DestroyWindow(mainwnd);
197 }
#define TRUE
Definition: types.h:120
#define SB_CTL
Definition: winuser.h:554
static HWND create_main_test_wnd(void)
Definition: scroll.c:56
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
BOOL WINAPI DestroyWindow(_In_ HWND)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
static HWND hScroll
Definition: scroll.c:28
int ret
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by START_TEST().

Variable Documentation

◆ bThemeActive

◆ hScroll