9e6468f65fd7a1a5d162b7f5a702770895b0c938
[reactos.git] / rostests / apitests / gdi32 / SetDCPenColor.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetDCPenColor
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8 #include <stdio.h>
9 #include <wine/test.h>
10 #include <windows.h>
11
12 void Test_SetDCPenColor()
13 {
14 HDC hScreenDC, hDC;
15 HBITMAP hbmp, hbmpOld;
16
17 // Test an incorrect DC
18 SetLastError(ERROR_SUCCESS);
19 ok(SetDCPenColor(0, RGB(0,0,0)) == CLR_INVALID, "\n");
20 ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n");
21
22 // Get the Screen DC
23 hScreenDC = GetDC(NULL);
24 ok(hScreenDC != 0, "GetDC failed, skipping tests\n");
25 if (hScreenDC == NULL) return;
26
27 // Test the screen DC
28 SetDCPenColor(hScreenDC, RGB(1,2,3));
29 ok(SetDCPenColor(hScreenDC, RGB(4,5,6)) == RGB(1,2,3), "\n");
30
31 // Create a new DC
32 hDC = CreateCompatibleDC(hScreenDC);
33 ReleaseDC(0, hScreenDC);
34 ok(hDC != 0, "CreateCompatibleDC failed, skipping tests\n");
35 if (!hDC) return;
36
37 // Select the DC_PEN and check if the pen returned by a new call is DC_PEN
38 SelectObject(hDC, GetStockObject(DC_PEN));
39 ok(SelectObject(hDC, GetStockObject(BLACK_PEN)) == GetStockObject(DC_PEN), "\n");
40
41 // Test an incorrect color, yes windows sets the color!
42 SetDCPenColor(hDC, 0x21123456);
43 ok(SetDCPenColor(hDC, RGB(0,0,0)) == 0x21123456, "\n");
44
45 // Test CLR_INVALID, it sets CLR_INVALID!
46 SetDCPenColor(hDC, CLR_INVALID);
47 ok(SetDCPenColor(hDC, RGB(0,0,0)) == CLR_INVALID, "\n");
48
49 hbmp = CreateBitmap(10, 10, 1, 32, NULL);
50 ok(hbmp != 0, "CreateBitmap failed, skipping tests\n");
51 if (!hbmp) return;
52 hbmpOld = SelectObject(hDC, hbmp);
53 #if 0 // this only works on 32 bpp screen resolution
54 ok(hbmpOld != NULL, "\n");
55 SelectObject(hDC, GetStockObject(DC_PEN));
56 SetDCPenColor(hDC, 0x123456);
57 MoveToEx(hDC, 0, 0, NULL);
58 LineTo(hDC, 10, 0);
59 ok(GetPixel(hDC, 5, 0) == 0x123456, "\n");
60 #endif
61
62 // Delete the DC
63 SelectObject(hDC, hbmpOld);
64 DeleteDC(hDC);
65 }
66
67 START_TEST(SetDCPenColor)
68 {
69 Test_SetDCPenColor();
70 }
71