ReactOS 0.4.16-dev-2491-g3dc6630
dce.c
Go to the documentation of this file.
1/*
2 * Unit tests for DCE support
3 *
4 * Copyright 2005 Alexandre Julliard
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <stdlib.h>
22#include <stdarg.h>
23#include <stdio.h>
24
25#include "windef.h"
26#include "winbase.h"
27#include "wingdi.h"
28#include "winuser.h"
29
30#include "wine/test.h"
31
32#ifndef DCX_USESTYLE
33#define DCX_USESTYLE 0x00010000
34#endif
35
37
38/* test behavior of DC attributes with various GetDC/ReleaseDC combinations */
39static void test_dc_attributes(void)
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 ) != hwnd_cache, "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 ) != hwnd_cache, "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}
200
201
202/* test behavior with various invalid parameters */
203static void test_parameters(void)
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}
227
228
229static void test_dc_visrgn(void)
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 );
374
375 hdc = GetDC( hwnd_parent );
376 GetClipBox( hdc, &parent_rect );
378
379 ok( EqualRect( &rect, &parent_rect ), "rect = %s, expected %s\n", wine_dbgstr_rect( &rect ),
380 wine_dbgstr_rect( &parent_rect ));
381}
382
383
384/* test various BeginPaint/EndPaint behaviors */
385static void test_begin_paint(void)
386{
387 HDC old_hdc, hdc;
388 RECT rect, parent_rect, client_rect;
389 PAINTSTRUCT ps;
390 COLORREF cr;
391
392 /* cache DC */
393
394 /* clear update region */
396 SetRect( &rect, 10, 10, 20, 20 );
398 hdc = BeginPaint( hwnd_cache, &ps );
399 SetRectEmpty( &rect );
400 GetClipBox( hdc, &rect );
401 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
402 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
403 EndPaint( hwnd_cache, &ps );
404
407 SetRect( &rect, 0, 0, 150, 150 );
409 hdc = BeginPaint( hwnd_cache, &ps );
410 GetClipBox( hdc, &rect );
411 GetClientRect( hwnd_cache, &client_rect );
412 ok( EqualRect( &rect, &client_rect ), "clip box = %s, expected %s\n",
413 wine_dbgstr_rect( &rect ), wine_dbgstr_rect( &client_rect ));
415 GetClipBox( hdc, &rect );
416 GetClientRect( hwnd_cache, &client_rect );
417 todo_wine ok( (!rect.left && !rect.top && rect.right == 150 && rect.bottom == 150) ||
418 broken( EqualRect( &rect, &client_rect )),
419 "clip box = %s\n", wine_dbgstr_rect( &rect ));
420 EndPaint( hwnd_cache, &ps );
421
424 hdc = BeginPaint( hwnd_cache, &ps );
426 GetClipBox( hdc, &rect );
427 GetClientRect( hwnd_cache, &client_rect );
428 todo_wine ok( EqualRect( &rect, &client_rect ), "clip box = %s, expected %s\n",
429 wine_dbgstr_rect( &rect ), wine_dbgstr_rect( &client_rect ));
430 EndPaint( hwnd_cache, &ps );
431
432 /* window DC */
433
435 SetRect( &rect, 10, 10, 20, 20 );
437 hdc = BeginPaint( hwnd_owndc, &ps );
438 SetRectEmpty( &rect );
439 GetClipBox( hdc, &rect );
440 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
441 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
443 SetRectEmpty( &rect );
444 GetClipBox( hdc, &rect );
445 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
446 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
447 ok( GetDC( hwnd_owndc ) == hdc, "got different hdc\n" );
448 SetRectEmpty( &rect );
449 GetClipBox( hdc, &rect );
450 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
451 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
452 EndPaint( hwnd_owndc, &ps );
453 SetRectEmpty( &rect );
454 GetClipBox( hdc, &rect );
455 ok( !(rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20),
456 "clip box should have been reset %s\n", wine_dbgstr_rect( &rect ));
458 SetRect( &rect, 10, 10, 20, 20 );
460 ok( GetDC( hwnd_owndc ) == hdc, "got different hdc\n" );
461 SetRectEmpty( &rect );
462 GetClipBox( hdc, &rect );
463 ok( !(rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20),
464 "clip box should be the whole window %s\n", wine_dbgstr_rect( &rect ));
466 SetRectEmpty( &rect );
467 GetClipBox( hdc, &rect );
468 ok( !(rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20),
469 "clip box should still be the whole window %s\n", wine_dbgstr_rect( &rect ));
470
473 SetRect( &rect, 0, 0, 50, 50 );
475 hdc = BeginPaint( hwnd_owndc, &ps );
476 GetClipBox( hdc, &rect );
477 ok( !rect.left && !rect.top && rect.right == 50 && rect.bottom == 50,
478 "clip box = %s\n", wine_dbgstr_rect( &rect ));
480 GetClipBox( hdc, &rect );
481 GetClientRect( hwnd_owndc, &client_rect );
482 ok( EqualRect( &rect, &client_rect ), "clip box = %s, expected %s\n",
483 wine_dbgstr_rect( &rect ), wine_dbgstr_rect( &client_rect ));
484 EndPaint( hwnd_owndc, &ps );
485
486 /* class DC */
487
489 SetRect( &rect, 10, 10, 20, 20 );
491 hdc = BeginPaint( hwnd_classdc, &ps );
492 SetRectEmpty( &rect );
493 GetClipBox( hdc, &rect );
494 ok( rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20,
495 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
496
497 old_hdc = hdc;
499 ok( old_hdc == hdc, "did not get the same hdc %p/%p\n", old_hdc, hdc );
500 SetRectEmpty( &rect );
501 GetClipBox( hdc, &rect );
502 ok( !(rect.left >= 10 && rect.top >= 10 && rect.right <= 20 && rect.bottom <= 20),
503 "clip box should have been reset %s\n", wine_dbgstr_rect( &rect ));
505 EndPaint( hwnd_classdc, &ps );
506
507 /* parent DC */
510 hdc = BeginPaint( hwnd_parentdc, &ps );
511 GetClipBox( hdc, &rect );
513 cr = SetPixel( hdc, 10, 10, RGB(255, 0, 0) );
514 ok( cr != -1, "error drawing outside of window client area\n" );
515 EndPaint( hwnd_parentdc, &ps );
516 GetClientRect( hwnd_parent, &parent_rect );
517
518 todo_wine ok( rect.left == parent_rect.left, "rect.left = %ld, expected %ld\n", rect.left, parent_rect.left );
519 todo_wine ok( rect.top == parent_rect.top, "rect.top = %ld, expected %ld\n", rect.top, parent_rect.top );
520 todo_wine ok( rect.right == parent_rect.right, "rect.right = %ld, expected %ld\n", rect.right, parent_rect.right );
521 todo_wine ok( rect.bottom == parent_rect.bottom, "rect.bottom = %ld, expected %ld\n", rect.bottom, parent_rect.bottom );
522
523 hdc = GetDC( hwnd_parent );
524 todo_wine ok( GetPixel( hdc, 60, 60 ) == cr, "error drawing outside of window client area\n" );
526}
527
528/* test ScrollWindow with window DCs */
529static void test_scroll_window(void)
530{
531 PAINTSTRUCT ps;
532 HDC hdc;
533 RECT clip, rect;
534
535 /* ScrollWindow uses the window DC, ScrollWindowEx doesn't */
536
538 SetRect( &clip, 25, 25, 50, 50 );
539 ScrollWindow( hwnd_owndc, -5, -10, NULL, &clip );
540 hdc = BeginPaint( hwnd_owndc, &ps );
541 SetRectEmpty( &rect );
542 GetClipBox( hdc, &rect );
543 ok( rect.left >= 25 && rect.top >= 25 && rect.right <= 50 && rect.bottom <= 50,
544 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
545 EndPaint( hwnd_owndc, &ps );
546
547 SetViewportExtEx( hdc, 2, 3, NULL );
548 SetViewportOrgEx( hdc, 30, 20, NULL );
549
550 ScrollWindow( hwnd_owndc, -5, -10, NULL, &clip );
551 hdc = BeginPaint( hwnd_owndc, &ps );
552 SetRectEmpty( &rect );
553 GetClipBox( hdc, &rect );
554 ok( rect.left >= 25 && rect.top >= 25 && rect.right <= 50 && rect.bottom <= 50,
555 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
556 EndPaint( hwnd_owndc, &ps );
557
558 ScrollWindowEx( hwnd_owndc, -5, -10, NULL, &clip, 0, NULL, SW_INVALIDATE | SW_ERASE );
559 hdc = BeginPaint( hwnd_owndc, &ps );
560 SetRectEmpty( &rect );
561 GetClipBox( hdc, &rect );
562 ok( rect.left >= -5 && rect.top >= 5 && rect.right <= 20 && rect.bottom <= 30,
563 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
564 EndPaint( hwnd_owndc, &ps );
565
566 SetViewportExtEx( hdc, 1, 1, NULL );
567 SetViewportOrgEx( hdc, 0, 0, NULL );
568
569 ScrollWindowEx( hwnd_owndc, -5, -10, NULL, &clip, 0, NULL, SW_INVALIDATE | SW_ERASE );
570 hdc = BeginPaint( hwnd_owndc, &ps );
571 SetRectEmpty( &rect );
572 GetClipBox( hdc, &rect );
573 ok( rect.left >= 25 && rect.top >= 25 && rect.right <= 50 && rect.bottom <= 50,
574 "invalid clip box %s\n", wine_dbgstr_rect( &rect ));
575 EndPaint( hwnd_owndc, &ps );
576}
577
578static void test_invisible_create(void)
579{
581 0, 200, 100, 100,
582 0, 0, GetModuleHandleA(0), NULL );
583 HDC dc1, dc2;
584
585 dc1 = GetDC(hwnd_owndc);
586 dc2 = GetDC(hwnd_owndc);
587
588 ok(dc1 == dc2, "expected owndc dcs to match\n");
589
590 ReleaseDC(hwnd_owndc, dc2);
591 ReleaseDC(hwnd_owndc, dc1);
593}
594
595static void test_dc_layout(void)
596{
597 HWND hwnd_cache_rtl, hwnd_owndc_rtl, hwnd_classdc_rtl, hwnd_classdc2_rtl;
598 HDC hdc;
600
601 hdc = GetDC( hwnd_cache );
603 layout = GetLayout( hdc );
605 if (!layout)
606 {
607 win_skip( "SetLayout not supported\n" );
608 return;
609 }
610
611 hwnd_cache_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "cache_class", NULL, WS_OVERLAPPED | WS_VISIBLE,
612 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL );
613 hwnd_owndc_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "owndc_class", NULL, WS_OVERLAPPED | WS_VISIBLE,
614 0, 200, 100, 100, 0, 0, GetModuleHandleA(0), NULL );
615 hwnd_classdc_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "classdc_class", NULL, WS_OVERLAPPED | WS_VISIBLE,
616 200, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL );
617 hwnd_classdc2_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "classdc_class", NULL, WS_OVERLAPPED | WS_VISIBLE,
618 200, 200, 100, 100, 0, 0, GetModuleHandleA(0), NULL );
619 hdc = GetDC( hwnd_cache_rtl );
620 layout = GetLayout( hdc );
621
622 ok( layout == LAYOUT_RTL, "wrong layout %lx\n", layout );
623 SetLayout( hdc, 0 );
624 ReleaseDC( hwnd_cache_rtl, hdc );
625 hdc = GetDC( hwnd_owndc_rtl );
626 layout = GetLayout( hdc );
627 ok( layout == LAYOUT_RTL, "wrong layout %lx\n", layout );
628 ReleaseDC( hwnd_cache_rtl, hdc );
629
630 hdc = GetDC( hwnd_cache );
631 layout = GetLayout( hdc );
632 ok( layout == 0, "wrong layout %lx\n", layout );
634
635 hdc = GetDC( hwnd_owndc_rtl );
636 layout = GetLayout( hdc );
637 ok( layout == LAYOUT_RTL, "wrong layout %lx\n", layout );
638 SetLayout( hdc, 0 );
639 ReleaseDC( hwnd_owndc_rtl, hdc );
640 hdc = GetDC( hwnd_owndc_rtl );
641 layout = GetLayout( hdc );
642 ok( layout == LAYOUT_RTL, "wrong layout %lx\n", layout );
643 ReleaseDC( hwnd_owndc_rtl, hdc );
644
645 hdc = GetDC( hwnd_classdc_rtl );
646 layout = GetLayout( hdc );
647 ok( layout == LAYOUT_RTL, "wrong layout %lx\n", layout );
648 SetLayout( hdc, 0 );
649 ReleaseDC( hwnd_classdc_rtl, hdc );
650 hdc = GetDC( hwnd_classdc2_rtl );
651 layout = GetLayout( hdc );
652 ok( layout == LAYOUT_RTL, "wrong layout %lx\n", layout );
653 ReleaseDC( hwnd_classdc2_rtl, hdc );
655 layout = GetLayout( hdc );
656 ok( layout == LAYOUT_RTL, "wrong layout %lx\n", layout );
657 ReleaseDC( hwnd_classdc_rtl, hdc );
658
659 DestroyWindow(hwnd_classdc2_rtl);
660 DestroyWindow(hwnd_classdc_rtl);
661 DestroyWindow(hwnd_owndc_rtl);
662 DestroyWindow(hwnd_cache_rtl);
663}
664
665static void test_destroyed_window(void)
666{
667 HDC dc, old_dc;
668 int rop;
669
670 dc = GetDC( hwnd_cache );
671 SetROP2( dc, R2_WHITE );
672 rop = GetROP2( dc );
673 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
674 ok( WindowFromDC( dc ) == hwnd_cache, "wrong window\n" );
675 old_dc = dc;
676
678 rop = GetROP2( dc );
679 ok( rop == 0, "wrong ROP2 %d\n", rop );
680 ok( WindowFromDC( dc ) != hwnd_cache, "wrong window\n" );
681 ok( !ReleaseDC( hwnd_cache, dc ), "ReleaseDC succeeded\n" );
682 dc = GetDC( hwnd_cache );
683 ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
684
685 dc = GetDC( hwnd_classdc );
686 SetROP2( dc, R2_WHITE );
687 rop = GetROP2( dc );
688 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
689 ok( WindowFromDC( dc ) == hwnd_classdc, "wrong window\n" );
690 old_dc = dc;
691
693 ok( old_dc == dc, "wrong DC\n" );
694 rop = GetROP2( dc );
695 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
696 ok( WindowFromDC( dc ) == hwnd_classdc2, "wrong window\n" );
698
699 rop = GetROP2( dc );
700 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
701 ok( WindowFromDC( dc ) != hwnd_classdc2, "wrong window\n" );
702 ok( !ReleaseDC( hwnd_classdc2, dc ), "ReleaseDC succeeded\n" );
704 ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
705
706 dc = GetDC( hwnd_classdc );
707 ok( dc != 0, "Got NULL DC\n" );
708 rop = GetROP2( dc );
709 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
710 ok( WindowFromDC( dc ) == hwnd_classdc, "wrong window\n" );
712
713 rop = GetROP2( dc );
714 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
715 ok( WindowFromDC( dc ) != hwnd_classdc, "wrong window\n" );
716 ok( !ReleaseDC( hwnd_classdc, dc ), "ReleaseDC succeeded\n" );
717 dc = GetDC( hwnd_classdc );
718 ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
719
720 dc = GetDC( hwnd_owndc );
721 ok( dc != 0, "Got NULL DC\n" );
722 rop = GetROP2( dc );
723 ok( rop == R2_WHITE, "wrong ROP2 %d\n", rop );
724 ok( WindowFromDC( dc ) == hwnd_owndc, "wrong window\n" );
726
727 rop = GetROP2( dc );
728 ok( rop == 0, "wrong ROP2 %d\n", rop );
729 ok( WindowFromDC( dc ) != hwnd_owndc, "wrong window\n" );
730 ok( !ReleaseDC( hwnd_owndc, dc ), "ReleaseDC succeeded\n" );
731 dc = GetDC( hwnd_owndc );
732 ok( !dc, "Got a non-NULL DC (%p) for a destroyed window\n", dc );
733
735}
736
738{
739 WNDCLASSA cls;
740
741 cls.style = CS_DBLCLKS;
743 cls.cbClsExtra = 0;
744 cls.cbWndExtra = 0;
746 cls.hIcon = 0;
749 cls.lpszMenuName = NULL;
750 cls.lpszClassName = "cache_class";
751 RegisterClassA(&cls);
752 cls.style = CS_DBLCLKS | CS_OWNDC;
753 cls.lpszClassName = "owndc_class";
754 RegisterClassA(&cls);
756 cls.lpszClassName = "classdc_class";
757 RegisterClassA(&cls);
758 cls.style = CS_PARENTDC;
759 cls.lpszClassName = "parentdc_class";
760 RegisterClassA(&cls);
761
763 0, 0, 100, 100,
764 0, 0, GetModuleHandleA(0), NULL );
766 0, 200, 100, 100,
767 0, 0, GetModuleHandleA(0), NULL );
769 200, 0, 100, 100,
770 0, 0, GetModuleHandleA(0), NULL );
772 200, 200, 100, 100,
773 0, 0, GetModuleHandleA(0), NULL );
775 400, 0, 100, 100, 0, 0, 0, NULL );
776 hwnd_parentdc = CreateWindowA("parentdc_class", NULL, WS_CHILD | WS_VISIBLE,
777 50, 50, 1, 1, hwnd_parent, 0, 0, NULL );
778
786 /* this should be last */
788}
static HRGN hrgn2
static HRGN hrgn
VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: bootvid.c:52
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
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
HDC dc
Definition: cylfrac.c:34
static HWND hwnd_parent
Definition: dce.c:36
static void test_invisible_create(void)
Definition: dce.c:578
static void test_scroll_window(void)
Definition: dce.c:529
static void test_begin_paint(void)
Definition: dce.c:385
static void test_destroyed_window(void)
Definition: dce.c:665
static HWND hwnd_cache
Definition: dce.c:36
static HWND hwnd_classdc
Definition: dce.c:36
#define DCX_USESTYLE
Definition: dce.c:33
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:595
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
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define RGB(r, g, b)
Definition: precomp.h:67
#define ERROR(name)
Definition: error_private.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetLayout(_In_ HDC hdc)
Definition: coord.c:750
DWORD WINAPI SetLayout(_In_ HDC hdc, _In_ DWORD dwLayout)
Definition: coord.c:780
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
#define win_skip
Definition: minitest.h:67
#define todo_wine
Definition: minitest.h:80
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static DWORD layout
Definition: bitmap.c:46
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
#define WS_CHILD
Definition: pedump.c:617
#define WS_OVERLAPPED
Definition: pedump.c:615
#define WS_VISIBLE
Definition: pedump.c:620
& rect
Definition: startmenu.cpp:1413
HBRUSH hbrBackground
Definition: winuser.h:3278
HICON hIcon
Definition: winuser.h:3276
HINSTANCE hInstance
Definition: winuser.h:3275
HCURSOR hCursor
Definition: winuser.h:3277
int cbWndExtra
Definition: winuser.h:3274
UINT style
Definition: winuser.h:3271
LPCSTR lpszMenuName
Definition: winuser.h:3279
LPCSTR lpszClassName
Definition: winuser.h:3280
WNDPROC lpfnWndProc
Definition: winuser.h:3272
int cbClsExtra
Definition: winuser.h:3273
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
int32_t INT
Definition: typedefs.h:58
DWORD COLORREF
Definition: windef.h:100
#define HORZRES
Definition: wingdi.h:716
#define R2_BLACK
Definition: wingdi.h:338
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
#define NUMCOLORS
Definition: wingdi.h:725
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
#define VERTRES
Definition: wingdi.h:717
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define WHITE_BRUSH
Definition: wingdi.h:902
int WINAPI GetROP2(_In_ HDC)
Definition: dc.c:1093
int WINAPI SetROP2(_In_ HDC, _In_ int)
Definition: dc.c:1114
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
#define R2_WHITE
Definition: wingdi.h:352
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define SWP_NOACTIVATE
Definition: winuser.h:1253
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
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)
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:4469
HWND WINAPI WindowFromDC(_In_ HDC hDC)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1255
#define SW_INVALIDATE
Definition: winuser.h:2615
#define IDC_ARROW
Definition: winuser.h:695
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define RDW_ERASE
Definition: winuser.h:1222
#define CS_DBLCLKS
Definition: winuser.h:659
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DCX_INTERSECTRGN
Definition: winuser.h:2158
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define RDW_ERASENOW
Definition: winuser.h:1230
BOOL WINAPI UpdateWindow(_In_ HWND)
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define SW_ERASE
Definition: winuser.h:2616
#define CS_OWNDC
Definition: winuser.h:663
#define CS_CLASSDC
Definition: winuser.h:658
#define RDW_NOFRAME
Definition: winuser.h:1227
#define DCX_EXCLUDERGN
Definition: winuser.h:2157
#define SWP_NOZORDER
Definition: winuser.h:1258
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define RDW_NOERASE
Definition: winuser.h:1226
#define CS_PARENTDC
Definition: winuser.h:664
#define RDW_VALIDATE
Definition: winuser.h:1229
BOOL WINAPI DestroyWindow(_In_ HWND)
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)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
#define DCX_NORESETATTRS
Definition: winuser.h:2154
#define RDW_INVALIDATE
Definition: winuser.h:1225
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2459
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
const char * LPCSTR
Definition: xmlstorage.h:183