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