ReactOS 0.4.15-dev-7693-gd0e2924
GetClipBox.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for GetClipBox
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8#include "precomp.h"
9
11{
12 HWND hWnd;
13 HDC hdc;
14 RECT rect;
15 HRGN hrgn, hrgn2;
16 int ret;
17
18 /* Create a window */
19 hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
21 NULL, NULL, 0, 0);
22 ok(hWnd != NULL, "CreateWindowW failed\n");
23 if (hWnd == NULL)
24 {
25 return;
26 }
27
28 hdc = GetDC(hWnd);
29
30 /* Test invalid DC */
32 ret = GetClipBox((HDC)0x12345, &rect);
33 ok(ret == ERROR, "Expected ERROR, got %d\n", ret);
34 ok((GetLastError() == 0) || (GetLastError() == ERROR_INVALID_HANDLE), "Expected 0, got %ld\n", GetLastError());
35
36 //ret = GetClipBox(hdc, &rect);
37 //ok_int(ret, SIMPLEREGION);
38 //ok_rect(&rect, 0, 0, 132, 68);
39
40 /* Create a clip region */
41 hrgn = CreateRectRgn(5, 7, 50, 50);
46 ok_rect(&rect, 5, 7, 50, 50);
47
48 /* Set clip region as meta region */
50
51 /* Create a new clip region */
52 hrgn = CreateRectRgn(10, 10, 100, 100);
57 ok_rect(&rect, 10, 10, 50, 50);
58
59 /* Create an empty clip region */
60 hrgn = CreateRectRgn(10, 10, 10, 30);
65 ok_rect(&rect, 0, 0, 0, 0);
66
67 /* Create a complex region */
68 hrgn = CreateRectRgn(10, 10, 30, 30);
69 hrgn2 = CreateRectRgn(20, 20, 60, 60);
75 ok_rect(&rect, 10, 10, 50, 50);
76
77 /* Set scaling but keep the mapping mode (viewport should not be changed) */
78 ok_int(SetViewportExtEx(hdc, 1000, 1000, NULL), 1);
81 ok_rect(&rect, 10, 10, 50, 50);
82
83 /* Set unisotropic mode, ClipBox should be unchanged */
87 ok_rect(&rect, 10, 10, 50, 50);
88
89 /* Now set viewport again */
90 ok_int(SetViewportExtEx(hdc, 200, 400, NULL), 1);
92 ok_int(ret, COMPLEXREGION); // obviously some special secret feature...
93 ok_rect(&rect, 0, 0, 0, 0);
94
95 /* Reset clip region */
100 ok_rect(&rect, 0, 0, 0, 0);
101
102 hrgn = CreateRectRgn(10, 10, 190, 190);
104 ret = GetClipBox(hdc, &rect);
106 ok_rect(&rect, 0, 0, 0, 0);
107
108 /* Now also set the window extension */
109 ok_int(SetWindowExtEx(hdc, 400, 600, NULL), 1);
110 ret = GetClipBox(hdc, &rect);
112 ok_rect(&rect, 20, 15, 100, 75);
113
114 hrgn = CreateRectRgn(30, 30, 300, 300);
117 ret = GetClipBox(hdc, &rect);
119 ok_rect(&rect, 60, 45, 100, 75);
120
123}
124
126{
128}
129
void Test_GetClipBox()
Definition: GetClipBox.c:10
static HRGN hrgn2
static HRGN hrgn
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define ok_rect(x, y)
Definition: atltypes.cpp:27
HWND hWnd
Definition: settings.c:17
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ERROR(name)
Definition: error_private.h:53
pKey DeleteObject()
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
& rect
Definition: startmenu.cpp:1413
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define COMPLEXREGION
Definition: wingdi.h:363
int WINAPI SetMapMode(_In_ HDC, _In_ int)
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
#define NULLREGION
Definition: wingdi.h:361
#define MM_ANISOTROPIC
Definition: wingdi.h:867
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
int WINAPI SetMetaRgn(_In_ HDC)
#define SIMPLEREGION
Definition: wingdi.h:362
#define RGN_OR
Definition: wingdi.h:359
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
#define CW_USEDEFAULT
Definition: winuser.h:225
BOOL WINAPI DestroyWindow(_In_ HWND)