ReactOS 0.4.15-dev-8061-g57b775e
ScrollBarWndExtra.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Test for ScrollBar cbWndExtra
5 * COPYRIGHT: Copyright 2019 Mark Jansen <mark.jansen@reactos.org>
6 *
7 * Why do we need this test?
8 * Ask the authors of Civilization II...
9 */
10
11#include "precomp.h"
12
13#define BUILTIN_SCROLLBAR "Scrollbar"
14#define CUSTOM_SCROLLBAR "MSScrollBarClass"
15
16
17
18START_TEST(ScrollBarWndExtra)
19{
20 HWND hScrollBar;
21 HWND hScrollBarImpersonator;
23 ATOM ClassAtom;
24
25 LONG_PTR dummyData = (LONG_PTR)0xbeefbeefbeefbeefULL, result;
26 WNDPROC lpfnWndProc;
27 DWORD dwExtra;
28
29 hScrollBar = CreateWindowExA(0, BUILTIN_SCROLLBAR, "", WS_POPUP,
30 20, 20, 120, 120, NULL, 0, GetModuleHandle(NULL), 0);
31
32 ok(hScrollBar != NULL, "Scrollbar creation failed (%lu)\n", GetLastError());
33
34 lpfnWndProc = (WNDPROC)GetWindowLongPtrA(hScrollBar, GWL_WNDPROC);
35 dwExtra = GetClassLongPtrA(hScrollBar, GCL_CBWNDEXTRA);
36
37 ZeroMemory(&WndClass, sizeof(WndClass));
39 WndClass.lpfnWndProc = lpfnWndProc;
40 WndClass.cbWndExtra = dwExtra + sizeof(LONG_PTR);
41 WndClass.hInstance = GetModuleHandle(NULL);
43 WndClass.hbrBackground = GetStockObject(LTGRAY_BRUSH);
44 WndClass.lpszClassName = CUSTOM_SCROLLBAR;
45 ClassAtom = RegisterClassA(&WndClass);
46
47 ok(ClassAtom != 0, "RegisterClassA failed (%lu)\n", GetLastError());
48 DestroyWindow(hScrollBar);
49
50
51 hScrollBarImpersonator = CreateWindowExA(0, CUSTOM_SCROLLBAR, "", WS_POPUP,
52 20, 20, 120, 120, NULL, 0, GetModuleHandle(NULL), 0);
53 ok(hScrollBarImpersonator != NULL, "Scrollbar creation failed (%lu)\n", GetLastError());
54
55 SetWindowLongPtrA(hScrollBarImpersonator, dwExtra, dummyData);
56 result = GetWindowLongPtrA(hScrollBarImpersonator, dwExtra);
57 ok(result == dummyData, "Invalid dummyData\n");
58
59 DestroyWindow(hScrollBarImpersonator);
61}
#define CUSTOM_SCROLLBAR
#define BUILTIN_SCROLLBAR
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
WCHAR WndClass[]
Definition: capicon.c:23
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint64EXT * result
Definition: glext.h:11304
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_POPUP
Definition: pedump.c:616
#define LONG_PTR
Definition: treelist.c:79
#define ZeroMemory
Definition: winbase.h:1712
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetModuleHandle
Definition: winbase.h:3827
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define LTGRAY_BRUSH
Definition: wingdi.h:900
#define CS_VREDRAW
Definition: winuser.h:658
#define SetWindowLongPtrA
Definition: winuser.h:5345
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 UnregisterClassA(_In_ LPCSTR, HINSTANCE)
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define GWL_WNDPROC
Definition: winuser.h:853
#define GetWindowLongPtrA
Definition: winuser.h:4828
#define CS_DBLCLKS
Definition: winuser.h:651
#define GCL_CBWNDEXTRA
Definition: winuser.h:663
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define LoadCursor
Definition: winuser.h:5812
#define GetClassLongPtrA
Definition: winuser.h:4563
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
#define CS_PARENTDC
Definition: winuser.h:656
BOOL WINAPI DestroyWindow(_In_ HWND)