ReactOS  0.4.14-dev-342-gdc047f9
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,
20  CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
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);
44  ret = GetClipBox(hdc, &rect);
46  ok_rect(&rect, 5, 7, 50, 50);
47 
48  /* Set clip region as meta region */
49  SetMetaRgn(hdc);
50 
51  /* Create a new clip region */
52  hrgn = CreateRectRgn(10, 10, 100, 100);
55  ret = GetClipBox(hdc, &rect);
57  ok_rect(&rect, 10, 10, 50, 50);
58 
59  /* Create an empty clip region */
60  hrgn = CreateRectRgn(10, 10, 10, 30);
63  ret = GetClipBox(hdc, &rect);
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);
73  ret = GetClipBox(hdc, &rect);
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);
79  ret = GetClipBox(hdc, &rect);
81  ok_rect(&rect, 10, 10, 50, 50);
82 
83  /* Set unisotropic mode, ClipBox should be unchanged */
85  ret = GetClipBox(hdc, &rect);
87  ok_rect(&rect, 10, 10, 50, 50);
88 
89  /* Now set viewport again */
90  ok_int(SetViewportExtEx(hdc, 200, 400, NULL), 1);
91  ret = GetClipBox(hdc, &rect);
92  ok_int(ret, COMPLEXREGION); // obviously some special secret feature...
93  ok_rect(&rect, 0, 0, 0, 0);
94 
95  /* Reset clip region */
97  SetMetaRgn(hdc);
98  ret = GetClipBox(hdc, &rect);
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);
116  SetMetaRgn(hdc);
117  ret = GetClipBox(hdc, &rect);
119  ok_rect(&rect, 60, 45, 100, 75);
120 
121  ReleaseDC(hWnd, hdc);
123 }
124 
126 {
127  Test_GetClipBox();
128 }
129 
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 SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define ERROR_SUCCESS
Definition: deptool.c:10
HDC WINAPI GetDC(_In_opt_ HWND)
#define ERROR(name)
Definition: error_private.h:53
static HRGN hrgn2
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
#define COMPLEXREGION
Definition: wingdi.h:362
#define NULLREGION
Definition: wingdi.h:360
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4217
& rect
Definition: startmenu.cpp:1413
START_TEST(GetClipBox)
Definition: GetClipBox.c:125
int WINAPI SetMapMode(_In_ HDC, _In_ int)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
#define RGN_OR
Definition: wingdi.h:358
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
void Test_GetClipBox()
Definition: GetClipBox.c:10
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
#define SetLastError(x)
Definition: compat.h:417
int WINAPI SetMetaRgn(_In_ HDC)
int ret
static const WCHAR L[]
Definition: oid.c:1250
HDC hdc
Definition: main.c:9
#define MM_ANISOTROPIC
Definition: wingdi.h:866
static HRGN hrgn
Definition: win.c:55
#define SIMPLEREGION
Definition: wingdi.h:361
#define ok(value,...)
Definition: atltest.h:57
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
#define WS_VISIBLE
Definition: pedump.c:620
#define ok_rect(x, y)
Definition: atltypes.cpp:23