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