2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetDCPenColor
5 * PROGRAMMERS: Timo Kreuzer
10 void Test_SetDCPenColor()
13 HBITMAP hbmp
, hbmpOld
;
15 // Test an incorrect DC
16 SetLastError(ERROR_SUCCESS
);
17 ok(SetDCPenColor(0, RGB(0,0,0)) == CLR_INVALID
, "\n");
18 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "\n");
21 hScreenDC
= GetDC(NULL
);
22 ok(hScreenDC
!= 0, "GetDC failed, skipping tests\n");
23 if (hScreenDC
== NULL
) return;
26 SetDCPenColor(hScreenDC
, RGB(1,2,3));
27 ok(SetDCPenColor(hScreenDC
, RGB(4,5,6)) == RGB(1,2,3), "\n");
30 hDC
= CreateCompatibleDC(hScreenDC
);
31 ReleaseDC(0, hScreenDC
);
32 ok(hDC
!= 0, "CreateCompatibleDC failed, skipping tests\n");
35 // Select the DC_PEN and check if the pen returned by a new call is DC_PEN
36 SelectObject(hDC
, GetStockObject(DC_PEN
));
37 ok(SelectObject(hDC
, GetStockObject(BLACK_PEN
)) == GetStockObject(DC_PEN
), "\n");
39 // Test an incorrect color, yes windows sets the color!
40 SetDCPenColor(hDC
, 0x21123456);
41 ok(SetDCPenColor(hDC
, RGB(0,0,0)) == 0x21123456, "\n");
43 // Test CLR_INVALID, it sets CLR_INVALID!
44 SetDCPenColor(hDC
, CLR_INVALID
);
45 ok(SetDCPenColor(hDC
, RGB(0,0,0)) == CLR_INVALID
, "\n");
47 hbmp
= CreateBitmap(10, 10, 1, 32, NULL
);
48 ok(hbmp
!= 0, "CreateBitmap failed, skipping tests\n");
50 hbmpOld
= SelectObject(hDC
, hbmp
);
51 #if 0 // this only works on 32 bpp screen resolution
52 ok(hbmpOld
!= NULL
, "\n");
53 SelectObject(hDC
, GetStockObject(DC_PEN
));
54 SetDCPenColor(hDC
, 0x123456);
55 MoveToEx(hDC
, 0, 0, NULL
);
57 ok(GetPixel(hDC
, 5, 0) == 0x123456, "\n");
61 SelectObject(hDC
, hbmpOld
);
65 START_TEST(SetDCPenColor
)