2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for CreateCompatibleDC
5 * PROGRAMMERS: Timo Kreuzer
10 void Test_CreateCompatibleDC()
12 HDC hdcScreen
, hOldDC
, hdc
, hdc2
;
17 hdcScreen
= GetDC(NULL
);
19 /* Test NULL DC handle */
20 SetLastError(ERROR_SUCCESS
);
21 hdc
= CreateCompatibleDC(NULL
);
22 ok(hdc
!= NULL
, "CreateCompatibleDC(NULL) failed\n");
23 ok(GetLastError() == ERROR_SUCCESS
, "GetLastError() == %ld\n", GetLastError());
24 if(hdc
) DeleteDC(hdc
);
26 /* Test invalid DC handle */
27 SetLastError(ERROR_SUCCESS
);
28 hdc
= CreateCompatibleDC((HDC
)0x123456);
29 ok(hdc
== NULL
, "Expected NULL, got %p\n", hdc
);
30 ok(GetLastError() == ERROR_SUCCESS
, "GetLastError() == %ld\n", GetLastError());
31 if(hdc
) DeleteDC(hdc
);
33 hdc
= CreateCompatibleDC(hdcScreen
);
34 ok(hdc
!= NULL
, "CreateCompatibleDC failed\n");
36 // Test if first selected pen is BLACK_PEN (? or same as screen DC's pen?)
37 hOldPen
= SelectObject(hdc
, GetStockObject(DC_PEN
));
38 ok (hOldPen
== GetStockObject(BLACK_PEN
), "hOldPen == %p\n", hOldPen
);
39 hOldPen
= SelectObject(hdc
, GetStockObject(BLACK_PEN
));
40 ok (hOldPen
== GetStockObject(DC_PEN
), "hOldPen == %p\n", hOldPen
);
42 /* Test for the starting Color == RGB(0,0,0) */
43 color
= SetDCPenColor(hdc
, RGB(1,2,3));
44 ok(color
== RGB(0,0,0), "color == %lx\n", color
);
46 /* Check for reuse counter */
49 hdc
= CreateCompatibleDC(hdcScreen
);
50 hdc2
= CreateCompatibleDC(hOldDC
);
51 ok(hdc2
== NULL
, "Expected NULL, got %p\n", hdc
);
52 if (hdc2
!= NULL
) DeleteDC(hdc2
);
55 hdc
= CreateCompatibleDC(hdcScreen
);
56 SetMapMode(hdc
, MM_ISOTROPIC
);
57 hdc2
= CreateCompatibleDC(hdc
);
58 ok(GetMapMode(hdc2
) == MM_TEXT
, "GetMapMode(hdc2)==%d\n", GetMapMode(hdc2
));
63 ReleaseDC(NULL
, hdcScreen
);
66 START_TEST(CreateCompatibleDC
)
68 Test_CreateCompatibleDC();