ReactOS 0.4.15-dev-7942-gd23573b
dce.c File Reference
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/test.h"
Include dependency graph for dce.c:

Go to the source code of this file.

Macros

#define DCX_USESTYLE   0x00010000
 

Functions

static void test_dc_attributes (void)
 
static void test_parameters (void)
 
static void test_dc_visrgn (void)
 
static void test_begin_paint (void)
 
static void test_scroll_window (void)
 
static void test_invisible_create (void)
 
static void test_dc_layout (void)
 
static void test_destroyed_window (void)
 
 START_TEST (dce)
 

Variables

static HWND hwnd_cache
 
static HWND hwnd_owndc
 
static HWND hwnd_classdc
 
static HWND hwnd_classdc2
 
static HWND hwnd_parent
 
static HWND hwnd_parentdc
 

Macro Definition Documentation

◆ DCX_USESTYLE

#define DCX_USESTYLE   0x00010000

Definition at line 33 of file dce.c.

Function Documentation

◆ START_TEST()

START_TEST ( dce  )

Definition at line 713 of file dce.c.

714{
715 WNDCLASSA cls;
716
717 cls.style = CS_DBLCLKS;
719 cls.cbClsExtra = 0;
720 cls.cbWndExtra = 0;
722 cls.hIcon = 0;
725 cls.lpszMenuName = NULL;
726 cls.lpszClassName = "cache_class";
727 RegisterClassA(&cls);
728 cls.style = CS_DBLCLKS | CS_OWNDC;
729 cls.lpszClassName = "owndc_class";
730 RegisterClassA(&cls);
732 cls.lpszClassName = "classdc_class";
733 RegisterClassA(&cls);
734 cls.style = CS_PARENTDC;
735 cls.lpszClassName = "parentdc_class";
736 RegisterClassA(&cls);
737
739 0, 0, 100, 100,
740 0, 0, GetModuleHandleA(0), NULL );
742 0, 200, 100, 100,
743 0, 0, GetModuleHandleA(0), NULL );
745 200, 0, 100, 100,
746 0, 0, GetModuleHandleA(0), NULL );
748 200, 200, 100, 100,
749 0, 0, GetModuleHandleA(0), NULL );
751 400, 0, 100, 100, 0, 0, 0, NULL );
752 hwnd_parentdc = CreateWindowA("parentdc_class", NULL, WS_CHILD | WS_VISIBLE,
753 0, 0, 1, 1, hwnd_parent, 0, 0, NULL );
754
762 /* this should be last */
764}
static HWND hwnd_parent
Definition: dce.c:36
static void test_invisible_create(void)
Definition: dce.c:534
static void test_scroll_window(void)
Definition: dce.c:485
static void test_begin_paint(void)
Definition: dce.c:384
static void test_destroyed_window(void)
Definition: dce.c:632
static HWND hwnd_cache
Definition: dce.c:36
static HWND hwnd_classdc
Definition: dce.c:36
static void test_parameters(void)
Definition: dce.c:203
static void test_dc_attributes(void)
Definition: dce.c:39
static HWND hwnd_parentdc
Definition: dce.c:36
static void test_dc_layout(void)
Definition: dce.c:551
static HWND hwnd_classdc2
Definition: dce.c:36
static void test_dc_visrgn(void)
Definition: dce.c:229
static HWND hwnd_owndc
Definition: dce.c:36
#define NULL
Definition: types.h:112
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define WS_CHILD
Definition: pedump.c:617
#define WS_OVERLAPPED
Definition: pedump.c:615
#define WS_VISIBLE
Definition: pedump.c:620
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define WHITE_BRUSH
Definition: wingdi.h:902
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define CS_OWNDC
Definition: winuser.h:655
#define CS_CLASSDC
Definition: winuser.h:650
#define CS_PARENTDC
Definition: winuser.h:656
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2090
const char * LPCSTR
Definition: xmlstorage.h:183

◆ test_begin_paint()

static void test_begin_paint ( void  )
static

Definition at line 384 of file dce.c.

385{
386 HDC old_hdc, hdc;
387 RECT rect, parent_rect;
388 PAINTSTRUCT ps;
389 COLORREF cr;
390
391 /* cache DC */
392
393 /* clear update region */
395 SetRect( &rect, 10, 10, 20, 20 );
397 hdc = BeginPaint( hwnd_cache, &ps );
398 SetRectEmpty( &rect );
399 GetClipBox( hdc, &rect );
400 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
401 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
402 EndPaint( hwnd_cache, &ps );
403
404 /* window DC */
405
407 SetRect( &rect, 10, 10, 20, 20 );
409 hdc = BeginPaint( hwnd_owndc, &ps );
410 SetRectEmpty( &rect );
411 GetClipBox( hdc, &rect );
412 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
413 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
415 SetRectEmpty( &rect );
416 GetClipBox( hdc, &rect );
417 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
418 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
419 ok( GetDC( hwnd_owndc ) == hdc, "got different hdc\n" );
420 SetRectEmpty( &rect );
421 GetClipBox( hdc, &rect );
422 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
423 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
424 EndPaint( hwnd_owndc, &ps );
425 SetRectEmpty( &rect );
426 GetClipBox( hdc, &rect );
427 ok( !(rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20),
428 "clip box should have been reset %s\n", wine_dbgstr_rect( &rect ));
430 SetRect( &rect, 10, 10, 20, 20 );
432 ok( GetDC( hwnd_owndc ) == hdc, "got different hdc\n" );
433 SetRectEmpty( &rect );
434 GetClipBox( hdc, &rect );
435 ok( !(rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20),
436 "clip box should be the whole window %s\n", wine_dbgstr_rect( &rect ));
438 SetRectEmpty( &rect );
439 GetClipBox( hdc, &rect );
440 ok( !(rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20),
441 "clip box should still be the whole window %s\n", wine_dbgstr_rect( &rect ));
442
443 /* class DC */
444
446 SetRect( &rect, 10, 10, 20, 20 );
448 hdc = BeginPaint( hwnd_classdc, &ps );
449 SetRectEmpty( &rect );
450 GetClipBox( hdc, &rect );
451 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
452 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
453
454 old_hdc = hdc;
456 ok( old_hdc == hdc, "did not get the same hdc %p/%p\n", old_hdc, hdc );
457 SetRectEmpty( &rect );
458 GetClipBox( hdc, &rect );
459 ok( !(rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20),
460 "clip box should have been reset %s\n", wine_dbgstr_rect( &rect ));
462 EndPaint( hwnd_classdc, &ps );
463
464 /* parent DC */
467 hdc = BeginPaint( hwnd_parentdc, &ps );
468 GetClipBox( hdc, &rect );
469 cr = SetPixel( hdc, 10, 10, RGB(255, 0, 0) );
470 ok( cr != -1, "error drawing outside of window client area\n" );
471 EndPaint( hwnd_parentdc, &ps );
472 GetClientRect( hwnd_parent, &parent_rect );
473
474 ok( rect.left == parent_rect.left, "rect.left = %d, expected %d\n", rect.left, parent_rect.left );
475 ok( rect.top == parent_rect.top, "rect.top = %d, expected %d\n", rect.top, parent_rect.top );
476 todo_wine ok( rect.right == parent_rect.right, "rect.right = %d, expected %d\n", rect.right, parent_rect.right );
477 todo_wine ok( rect.bottom == parent_rect.bottom, "rect.bottom = %d, expected %d\n", rect.bottom, parent_rect.bottom );
478
479 hdc = GetDC( hwnd_parent );
480 todo_wine ok( GetPixel( hdc, 10, 10 ) == cr, "error drawing outside of window client area\n" );
482}
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:55
#define ok(value,...)
Definition: atltest.h:57
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define RGB(r, g, b)
Definition: precomp.h:71
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
#define todo_wine
Definition: custom.c:79
& rect
Definition: startmenu.cpp:1413
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
DWORD COLORREF
Definition: windef.h:300
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define RDW_ERASE
Definition: winuser.h:1211
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define RDW_ERASENOW
Definition: winuser.h:1219
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define RDW_NOFRAME
Definition: winuser.h:1216
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define RDW_NOERASE
Definition: winuser.h:1215
#define RDW_VALIDATE
Definition: winuser.h:1218
#define RDW_INVALIDATE
Definition: winuser.h:1214
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by START_TEST().

◆ test_dc_attributes()

static void test_dc_attributes ( void  )
static

Definition at line 39 of file dce.c.

40{
41 HDC hdc, old_hdc;
42 HDC hdcs[20];
43 INT i, rop, def_rop, caps;
44 BOOL found_dc;
45
46 /* test cache DC */
47
48 hdc = GetDC( hwnd_cache );
49 def_rop = GetROP2( hdc );
50
52 rop = GetROP2( hdc );
53 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
54
55 ok( WindowFromDC( hdc ) == hwnd_cache, "wrong window\n" );
57 ok( WindowFromDC( hdc ) == 0, "wrong window\n" );
58 hdc = GetDC( hwnd_cache );
59 rop = GetROP2( hdc );
60 ok( rop == def_rop, "wrong ROP2 %d after release\n", rop );
62 ok( WindowFromDC( hdc ) == hwnd_cache, "wrong window\n" );
64 old_hdc = hdc;
65
66 found_dc = FALSE;
67 for (i = 0; i < 20; i++)
68 {
70 if (!hdc) break;
71 rop = GetROP2( hdc );
72 ok( rop == def_rop, "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc );
73 if (hdc == old_hdc)
74 {
75 found_dc = TRUE;
77 }
78 }
79 if (!found_dc)
80 {
81 trace( "hdc %p not found in cache using %p\n", old_hdc, hdcs[0] );
82 old_hdc = hdcs[0];
83 SetROP2( old_hdc, R2_WHITE );
84 }
85 while (i > 0) ReleaseDC( hwnd_cache, hdcs[--i] );
86
87 for (i = 0; i < 20; i++)
88 {
90 if (!hdc) break;
91 rop = GetROP2( hdc );
92 if (hdc == old_hdc)
93 ok( rop == R2_WHITE || broken( rop == def_rop), /* win9x doesn't support DCX_NORESETATTRS */
94 "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc );
95 else
96 ok( rop == def_rop, "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc );
97 }
98 while (i > 0) ReleaseDC( hwnd_cache, hdcs[--i] );
99
100 for (i = 0; i < 20; i++)
101 {
102 hdc = hdcs[i] = GetDCEx( hwnd_cache, 0, DCX_USESTYLE );
103 if (!hdc) break;
104 rop = GetROP2( hdc );
105 if (hdc == old_hdc)
106 {
107 ok( rop == R2_WHITE || broken( rop == def_rop),
108 "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc );
109 SetROP2( old_hdc, def_rop );
110 }
111 else
112 ok( rop == def_rop, "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc );
113 }
114 while (i > 0) ReleaseDC( hwnd_cache, hdcs[--i] );
115
116 /* Released cache DCs are 'disabled' */
117 rop = SetROP2( old_hdc, R2_BLACK );
118 ok( rop == 0, "got %d\n", rop );
119 rop = GetROP2( old_hdc );
120 ok( rop == 0, "got %d\n", rop );
121 caps = GetDeviceCaps( old_hdc, HORZRES );
122 ok( caps == 0, "got %d\n", caps );
123 caps = GetDeviceCaps( old_hdc, VERTRES );
124 ok( caps == 0, "got %d\n", caps );
125 caps = GetDeviceCaps( old_hdc, NUMCOLORS );
126 ok( caps == 0, "got %d\n", caps );
127 ok( WindowFromDC( old_hdc ) == 0, "wrong window\n" );
128
129 hdc = GetDC(0);
130 caps = GetDeviceCaps( hdc, HORZRES );
131 ok( caps != 0, "got %d\n", caps );
132 caps = GetDeviceCaps( hdc, VERTRES );
133 ok( caps != 0, "got %d\n", caps );
134 caps = GetDeviceCaps( hdc, NUMCOLORS );
135 ok( caps != 0, "got %d\n", caps );
136 ReleaseDC( 0, hdc );
137 caps = GetDeviceCaps( hdc, HORZRES );
138 ok( caps == 0, "got %d\n", caps );
139 caps = GetDeviceCaps( hdc, VERTRES );
140 ok( caps == 0, "got %d\n", caps );
141 caps = GetDeviceCaps( hdc, NUMCOLORS );
142 ok( caps == 0, "got %d\n", caps );
143
144 /* test own DC */
145
146 hdc = GetDC( hwnd_owndc );
147 SetROP2( hdc, R2_WHITE );
148 rop = GetROP2( hdc );
149 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
150
151 old_hdc = hdc;
152 ok( WindowFromDC( hdc ) == hwnd_owndc, "wrong window\n" );
154 ok( WindowFromDC( hdc ) == hwnd_owndc, "wrong window\n" );
155 hdc = GetDC( hwnd_owndc );
156 ok( old_hdc == hdc, "didn't get same DC %p/%p\n", old_hdc, hdc );
157 rop = GetROP2( hdc );
158 ok( rop == R2_WHITE, "wrong ROP2 %d after release\n", rop );
159 ok( WindowFromDC( hdc ) == hwnd_owndc, "wrong window\n" );
161 rop = GetROP2( hdc );
162 ok( rop == R2_WHITE, "wrong ROP2 %d after second release\n", rop );
163
164 /* test class DC */
165
167 SetROP2( hdc, R2_WHITE );
168 rop = GetROP2( hdc );
169 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
170
171 old_hdc = hdc;
172 ok( WindowFromDC( hdc ) == hwnd_classdc, "wrong window\n" );
174 ok( WindowFromDC( hdc ) == hwnd_classdc, "wrong window\n" );
176 ok( old_hdc == hdc, "didn't get same DC %p/%p\n", old_hdc, hdc );
177 rop = GetROP2( hdc );
178 ok( rop == R2_WHITE, "wrong ROP2 %d after release\n", rop );
179 ok( WindowFromDC( hdc ) == hwnd_classdc, "wrong window\n" );
181 rop = GetROP2( hdc );
182 ok( rop == R2_WHITE, "wrong ROP2 %d after second release\n", rop );
183
184 /* test class DC with 2 windows */
185
186 old_hdc = GetDC( hwnd_classdc );
187 SetROP2( old_hdc, R2_BLACK );
188 ok( WindowFromDC( old_hdc ) == hwnd_classdc, "wrong window\n" );
190 ok( old_hdc == hdc, "didn't get same DC %p/%p\n", old_hdc, hdc );
191 rop = GetROP2( hdc );
192 ok( rop == R2_BLACK, "wrong ROP2 %d for other window\n", rop );
193 ok( WindowFromDC( hdc ) == hwnd_classdc2, "wrong window\n" );
194 ReleaseDC( hwnd_classdc, old_hdc );
196 ok( WindowFromDC( hdc ) == hwnd_classdc2, "wrong window\n" );
197 rop = GetROP2( hdc );
198 ok( rop == R2_BLACK, "wrong ROP2 %d after release\n", rop );
199}
#define broken(x)
Definition: _sntprintf.h:21
#define trace
Definition: atltest.h:70
#define DCX_USESTYLE
Definition: dce.c:33
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
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
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
int32_t INT
Definition: typedefs.h:58
#define HORZRES
Definition: wingdi.h:716
#define R2_BLACK
Definition: wingdi.h:338
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define NUMCOLORS
Definition: wingdi.h:725
#define VERTRES
Definition: wingdi.h:717
int WINAPI GetROP2(_In_ HDC)
Definition: dc.c:1086
int WINAPI SetROP2(_In_ HDC, _In_ int)
Definition: dc.c:1107
#define R2_WHITE
Definition: wingdi.h:352
HWND WINAPI WindowFromDC(_In_ HDC hDC)
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define DCX_NORESETATTRS
Definition: winuser.h:2118

Referenced by START_TEST().

◆ test_dc_layout()

static void test_dc_layout ( void  )
static

Definition at line 551 of file dce.c.

552{
553 DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout);
554 DWORD (WINAPI *pGetLayout)(HDC hdc);
555 HWND hwnd_cache_rtl, hwnd_owndc_rtl, hwnd_classdc_rtl, hwnd_classdc2_rtl;
556 HDC hdc;
558 HMODULE mod = GetModuleHandleA("gdi32.dll");
559
560 pGetLayout = (void *)GetProcAddress( mod, "GetLayout" );
561 pSetLayout = (void *)GetProcAddress( mod, "SetLayout" );
562 if (!pGetLayout || !pSetLayout)
563 {
564 win_skip( "Don't have SetLayout\n" );
565 return;
566 }
567
568 hdc = GetDC( hwnd_cache );
569 pSetLayout( hdc, LAYOUT_RTL );
570 layout = pGetLayout( hdc );
572 if (!layout)
573 {
574 win_skip( "SetLayout not supported\n" );
575 return;
576 }
577
578 hwnd_cache_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "cache_class", NULL, WS_OVERLAPPED | WS_VISIBLE,
579 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL );
580 hwnd_owndc_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "owndc_class", NULL, WS_OVERLAPPED | WS_VISIBLE,
581 0, 200, 100, 100, 0, 0, GetModuleHandleA(0), NULL );
582 hwnd_classdc_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "classdc_class", NULL, WS_OVERLAPPED | WS_VISIBLE,
583 200, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL );
584 hwnd_classdc2_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "classdc_class", NULL, WS_OVERLAPPED | WS_VISIBLE,
585 200, 200, 100, 100, 0, 0, GetModuleHandleA(0), NULL );
586 hdc = GetDC( hwnd_cache_rtl );
587 layout = pGetLayout( hdc );
588
589 ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
590 pSetLayout( hdc, 0 );
591 ReleaseDC( hwnd_cache_rtl, hdc );
592 hdc = GetDC( hwnd_owndc_rtl );
593 layout = pGetLayout( hdc );
594 ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
595 ReleaseDC( hwnd_cache_rtl, hdc );
596
597 hdc = GetDC( hwnd_cache );
598 layout = pGetLayout( hdc );
599 ok( layout == 0, "wrong layout %x\n", layout );
601
602 hdc = GetDC( hwnd_owndc_rtl );
603 layout = pGetLayout( hdc );
604 ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
605 pSetLayout( hdc, 0 );
606 ReleaseDC( hwnd_owndc_rtl, hdc );
607 hdc = GetDC( hwnd_owndc_rtl );
608 layout = pGetLayout( hdc );
609 ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
610 ReleaseDC( hwnd_owndc_rtl, hdc );
611
612 hdc = GetDC( hwnd_classdc_rtl );
613 layout = pGetLayout( hdc );
614 ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
615 pSetLayout( hdc, 0 );
616 ReleaseDC( hwnd_classdc_rtl, hdc );
617 hdc = GetDC( hwnd_classdc2_rtl );
618 layout = pGetLayout( hdc );
619 ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
620 ReleaseDC( hwnd_classdc2_rtl, hdc );
622 layout = pGetLayout( hdc );
623 ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
624 ReleaseDC( hwnd_classdc_rtl, hdc );
625
626 DestroyWindow(hwnd_classdc2_rtl);
627 DestroyWindow(hwnd_classdc_rtl);
628 DestroyWindow(hwnd_owndc_rtl);
629 DestroyWindow(hwnd_cache_rtl);
630}
#define GetProcAddress(x, y)
Definition: compat.h:753
unsigned long DWORD
Definition: ntddk_ex.h:95
static int mod
Definition: i386-dis.c:1288
static DWORD layout
Definition: bitmap.c:46
#define DWORD
Definition: nt_native.h:44
#define win_skip
Definition: test.h:160
#define WINAPI
Definition: msvc.h:6
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
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 DestroyWindow(_In_ HWND)

Referenced by START_TEST().

◆ test_dc_visrgn()

static void test_dc_visrgn ( void  )
static

Definition at line 229 of file dce.c.

230{
231 HDC old_hdc, hdc;
232 HRGN hrgn, hrgn2;
233 RECT rect, parent_rect;
234
235 /* cache DC */
236
237 SetRect( &rect, 10, 10, 20, 20 );
238 MapWindowPoints( hwnd_cache, 0, (POINT *)&rect, 2 );
241 SetRectEmpty( &rect );
242 GetClipBox( hdc, &rect );
243 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
244 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
245 ok( GetRgnBox( hrgn, &rect ) != ERROR, "region must still be valid\n" );
247 ok( GetRgnBox( hrgn, &rect ) == ERROR, "region must no longer be valid\n" );
248
249 /* cache DC with NORESETATTRS */
250
251 SetRect( &rect, 10, 10, 20, 20 );
252 MapWindowPoints( hwnd_cache, 0, (POINT *)&rect, 2 );
255 SetRectEmpty( &rect );
256 GetClipBox( hdc, &rect );
257 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
258 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
259 ok( GetRgnBox( hrgn, &rect ) != ERROR, "region must still be valid\n" );
261 ok( GetRgnBox( hrgn, &rect ) == ERROR, "region must no longer be valid\n" );
263 SetRectEmpty( &rect );
264 GetClipBox( hdc, &rect );
265 ok( !(rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20),
266 "clip box should have been reset %s\n", wine_dbgstr_rect( &rect ));
268
269 /* window DC */
270
271 SetRect( &rect, 10, 10, 20, 20 );
272 MapWindowPoints( hwnd_owndc, 0, (POINT *)&rect, 2 );
275 SetRectEmpty( &rect );
276 GetClipBox( hdc, &rect );
277 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
278 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
279 ok( GetRgnBox( hrgn, &rect ) != ERROR, "region must still be valid\n" );
281 ok( GetRgnBox( hrgn, &rect ) != ERROR, "region must still be valid\n" );
282 SetRectEmpty( &rect );
283 GetClipBox( hdc, &rect );
284 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
285 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
287 SetRectEmpty( &rect );
288 GetClipBox( hdc, &rect );
289 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
290 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
291 ok( GetRgnBox( hrgn, &rect ) != ERROR, "region must still be valid\n" );
293 ok( GetRgnBox( hrgn, &rect ) != ERROR, "region must still be valid\n" );
294
295 SetRect( &rect, 20, 20, 30, 30 );
296 MapWindowPoints( hwnd_owndc, 0, (POINT *)&rect, 2 );
299 ok( GetRgnBox( hrgn, &rect ) == ERROR, "region must no longer be valid\n" );
300 SetRectEmpty( &rect );
301 GetClipBox( hdc, &rect );
302 ok( rect.left >= 20 && rect.top >= 20 && rect.right <= 30 && rect.bottom <= 30,
303 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
304 ok( GetRgnBox( hrgn2, &rect ) != ERROR, "region2 must still be valid\n" );
306 ok( GetRgnBox( hrgn2, &rect ) != ERROR, "region2 must still be valid\n" );
308 ok( GetRgnBox( hrgn2, &rect ) == ERROR, "region must no longer be valid\n" );
309 SetRectEmpty( &rect );
310 GetClipBox( hdc, &rect );
311 ok( !(rect.left >= 20 && rect.top >= 20 && rect.right <= 30 && rect.bottom <= 30),
312 "clip box should have been reset %s\n", wine_dbgstr_rect( &rect ));
314
315 /* class DC */
316
317 SetRect( &rect, 10, 10, 20, 20 );
321 SetRectEmpty( &rect );
322 GetClipBox( hdc, &rect );
323 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
324 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
325 ok( GetRgnBox( hrgn, &rect ) != ERROR, "region must still be valid\n" );
327 ok( GetRgnBox( hrgn, &rect ) != ERROR, "region must still be valid\n" );
328 SetRectEmpty( &rect );
329 GetClipBox( hdc, &rect );
330 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
331 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
332
334 SetRectEmpty( &rect );
335 GetClipBox( hdc, &rect );
336 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
337 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
338 ok( GetRgnBox( hrgn, &rect ) != ERROR, "region must still be valid\n" );
340 ok( GetRgnBox( hrgn, &rect ) != ERROR, "region must still be valid\n" );
341
342 SetRect( &rect, 20, 20, 30, 30 );
346 ok( GetRgnBox( hrgn, &rect ) == ERROR, "region must no longer be valid\n" );
347 SetRectEmpty( &rect );
348 GetClipBox( hdc, &rect );
349 ok( rect.left >= 20 && rect.top >= 20 && rect.right <= 30 && rect.bottom <= 30,
350 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
351 ok( GetRgnBox( hrgn2, &rect ) != ERROR, "region2 must still be valid\n" );
352
353 old_hdc = hdc;
355 ok( old_hdc == hdc, "did not get the same hdc %p/%p\n", old_hdc, hdc );
356 ok( GetRgnBox( hrgn2, &rect ) != ERROR, "region2 must still be valid\n" );
357 SetRectEmpty( &rect );
358 GetClipBox( hdc, &rect );
359 ok( !(rect.left >= 20 && rect.top >= 20 && rect.right <= 30 && rect.bottom <= 30),
360 "clip box should have been reset %s\n", wine_dbgstr_rect( &rect ));
362 ok( GetRgnBox( hrgn2, &rect ) != ERROR, "region2 must still be valid\n" );
364 ok( GetRgnBox( hrgn2, &rect ) != ERROR, "region2 must still be valid\n" );
365 ok( !(rect.left >= 20 && rect.top >= 20 && rect.right <= 30 && rect.bottom <= 30),
366 "clip box must have been reset %s\n", wine_dbgstr_rect( &rect ));
368
369 /* parent DC */
371 GetClipBox( hdc, &rect );
373
374 hdc = GetDC( hwnd_parent );
375 GetClipBox( hdc, &parent_rect );
377
378 ok( EqualRect( &rect, &parent_rect ), "rect = %s, expected %s\n", wine_dbgstr_rect( &rect ),
379 wine_dbgstr_rect( &parent_rect ));
380}
static HRGN hrgn2
static HRGN hrgn
#define ERROR(name)
Definition: error_private.h:53
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define DCX_INTERSECTRGN
Definition: winuser.h:2122
#define DCX_EXCLUDERGN
Definition: winuser.h:2121
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)

Referenced by START_TEST().

◆ test_destroyed_window()

static void test_destroyed_window ( void  )
static

Definition at line 632 of file dce.c.

633{
634 HDC dc, old_dc;
635 HDC hdcs[30];
636 int i, rop;
637
638 dc = GetDC( hwnd_cache );
639 SetROP2( dc, R2_WHITE );
640 rop = GetROP2( dc );
641 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
642 ok( WindowFromDC( dc ) == hwnd_cache, "wrong window\n" );
643 old_dc = dc;
644
646 rop = GetROP2( dc );
647 ok( rop == 0, "wrong ROP2 %d\n", rop );
648 ok( WindowFromDC( dc ) == 0, "wrong window\n" );
649 ok( !ReleaseDC( hwnd_cache, dc ), "ReleaseDC succeeded\n" );
650 dc = GetDC( hwnd_cache );
651 ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
652
653 for (i = 0; i < 30; i++)
654 {
655 dc = hdcs[i] = GetDCEx( hwnd_parent, 0, DCX_CACHE | DCX_USESTYLE );
656 if (dc == old_dc) break;
657 }
658 ok( i < 30, "DC for destroyed window not reused\n" );
659 while (i > 0) ReleaseDC( hwnd_parent, hdcs[--i] );
660
661 dc = GetDC( hwnd_classdc );
662 SetROP2( dc, R2_WHITE );
663 rop = GetROP2( dc );
664 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
665 ok( WindowFromDC( dc ) == hwnd_classdc, "wrong window\n" );
666 old_dc = dc;
667
669 ok( old_dc == dc, "wrong DC\n" );
670 rop = GetROP2( dc );
671 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
672 ok( WindowFromDC( dc ) == hwnd_classdc2, "wrong window\n" );
674
675 rop = GetROP2( dc );
676 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
677 ok( WindowFromDC( dc ) == 0, "wrong window\n" );
678 ok( !ReleaseDC( hwnd_classdc2, dc ), "ReleaseDC succeeded\n" );
680 ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
681
682 dc = GetDC( hwnd_classdc );
683 ok( dc != 0, "Got NULL DC\n" );
684 rop = GetROP2( dc );
685 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
686 ok( WindowFromDC( dc ) == hwnd_classdc, "wrong window\n" );
688
689 rop = GetROP2( dc );
690 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
691 ok( WindowFromDC( dc ) == 0, "wrong window\n" );
692 ok( !ReleaseDC( hwnd_classdc, dc ), "ReleaseDC succeeded\n" );
693 dc = GetDC( hwnd_classdc );
694 ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
695
696 dc = GetDC( hwnd_owndc );
697 ok( dc != 0, "Got NULL DC\n" );
698 rop = GetROP2( dc );
699 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
700 ok( WindowFromDC( dc ) == hwnd_owndc, "wrong window\n" );
702
703 rop = GetROP2( dc );
704 ok( rop == 0, "wrong ROP2 %d\n", rop );
705 ok( WindowFromDC( dc ) == 0, "wrong window\n" );
706 ok( !ReleaseDC( hwnd_owndc, dc ), "ReleaseDC succeeded\n" );
707 dc = GetDC( hwnd_owndc );
708 ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
709
711}
static const WCHAR dc[]
#define DCX_CACHE
Definition: winuser.h:2114

Referenced by START_TEST().

◆ test_invisible_create()

static void test_invisible_create ( void  )
static

Definition at line 534 of file dce.c.

535{
537 0, 200, 100, 100,
538 0, 0, GetModuleHandleA(0), NULL );
539 HDC dc1, dc2;
540
541 dc1 = GetDC(hwnd_owndc);
542 dc2 = GetDC(hwnd_owndc);
543
544 ok(dc1 == dc2, "expected owndc dcs to match\n");
545
546 ReleaseDC(hwnd_owndc, dc2);
547 ReleaseDC(hwnd_owndc, dc1);
549}

Referenced by START_TEST().

◆ test_parameters()

static void test_parameters ( void  )
static

Definition at line 203 of file dce.c.

204{
205 HDC hdc;
206
207 hdc = GetDC( hwnd_cache );
208 ok( ReleaseDC( hwnd_owndc, hdc ), "ReleaseDC with wrong window should succeed\n" );
209
210 hdc = GetDC( hwnd_cache );
211 ok( !ReleaseDC( hwnd_cache, 0 ), "ReleaseDC with wrong HDC should fail\n" );
212 ok( ReleaseDC( hwnd_cache, hdc ), "correct ReleaseDC should succeed\n" );
213 ok( !ReleaseDC( hwnd_cache, hdc ), "second ReleaseDC should fail\n" );
214
215 hdc = GetDC( hwnd_owndc );
216 ok( ReleaseDC( hwnd_cache, hdc ), "ReleaseDC with wrong window should succeed\n" );
217 hdc = GetDC( hwnd_owndc );
218 ok( ReleaseDC( hwnd_owndc, hdc ), "correct ReleaseDC should succeed\n" );
219 ok( ReleaseDC( hwnd_owndc, hdc ), "second ReleaseDC should succeed\n" );
220
222 ok( ReleaseDC( hwnd_cache, hdc ), "ReleaseDC with wrong window should succeed\n" );
224 ok( ReleaseDC( hwnd_classdc, hdc ), "correct ReleaseDC should succeed\n" );
225 ok( ReleaseDC( hwnd_classdc, hdc ), "second ReleaseDC should succeed\n" );
226}

Referenced by START_TEST().

◆ test_scroll_window()

static void test_scroll_window ( void  )
static

Definition at line 485 of file dce.c.

486{
487 PAINTSTRUCT ps;
488 HDC hdc;
489 RECT clip, rect;
490
491 /* ScrollWindow uses the window DC, ScrollWindowEx doesn't */
492
494 SetRect( &clip, 25, 25, 50, 50 );
495 ScrollWindow( hwnd_owndc, -5, -10, NULL, &clip );
496 hdc = BeginPaint( hwnd_owndc, &ps );
497 SetRectEmpty( &rect );
498 GetClipBox( hdc, &rect );
499 ok( rect.left >= 25 && rect.top >= 25 && rect.right <= 50 && rect.bottom <= 50,
500 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
501 EndPaint( hwnd_owndc, &ps );
502
503 SetViewportExtEx( hdc, 2, 3, NULL );
504 SetViewportOrgEx( hdc, 30, 20, NULL );
505
506 ScrollWindow( hwnd_owndc, -5, -10, NULL, &clip );
507 hdc = BeginPaint( hwnd_owndc, &ps );
508 SetRectEmpty( &rect );
509 GetClipBox( hdc, &rect );
510 ok( rect.left >= 25 && rect.top >= 25 && rect.right <= 50 && rect.bottom <= 50,
511 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
512 EndPaint( hwnd_owndc, &ps );
513
514 ScrollWindowEx( hwnd_owndc, -5, -10, NULL, &clip, 0, NULL, SW_INVALIDATE | SW_ERASE );
515 hdc = BeginPaint( hwnd_owndc, &ps );
516 SetRectEmpty( &rect );
517 GetClipBox( hdc, &rect );
518 ok( rect.left >= -5 && rect.top >= 5 && rect.right <= 20 && rect.bottom <= 30,
519 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
520 EndPaint( hwnd_owndc, &ps );
521
522 SetViewportExtEx( hdc, 1, 1, NULL );
523 SetViewportOrgEx( hdc, 0, 0, NULL );
524
525 ScrollWindowEx( hwnd_owndc, -5, -10, NULL, &clip, 0, NULL, SW_INVALIDATE | SW_ERASE );
526 hdc = BeginPaint( hwnd_owndc, &ps );
527 SetRectEmpty( &rect );
528 GetClipBox( hdc, &rect );
529 ok( rect.left >= 25 && rect.top >= 25 && rect.right <= 50 && rect.bottom <= 50,
530 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
531 EndPaint( hwnd_owndc, &ps );
532}
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
#define SW_INVALIDATE
Definition: winuser.h:2579
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SW_ERASE
Definition: winuser.h:2580
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
BOOL WINAPI ScrollWindow(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT)

Referenced by START_TEST().

Variable Documentation

◆ hwnd_cache

◆ hwnd_classdc

◆ hwnd_classdc2

HWND hwnd_classdc2
static

◆ hwnd_owndc

◆ hwnd_parent

HWND hwnd_parent
static

◆ hwnd_parentdc

HWND hwnd_parentdc
static

Definition at line 36 of file dce.c.

Referenced by START_TEST(), test_begin_paint(), and test_dc_visrgn().