ReactOS  0.4.14-dev-317-g96040ec
SetDCPenColor.c
Go to the documentation of this file.
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 "precomp.h"
9 
11 {
12  HDC hScreenDC, hDC;
14 
15  // Test an incorrect DC
17  ok(SetDCPenColor(0, RGB(0,0,0)) == CLR_INVALID, "\n");
19 
20  // Get the Screen DC
21  hScreenDC = GetDC(NULL);
22  ok(hScreenDC != 0, "GetDC failed, skipping tests\n");
23  if (hScreenDC == NULL) return;
24 
25  // Test the screen DC
26  SetDCPenColor(hScreenDC, RGB(1,2,3));
27  ok(SetDCPenColor(hScreenDC, RGB(4,5,6)) == RGB(1,2,3), "\n");
28 
29  // Create a new DC
30  hDC = CreateCompatibleDC(hScreenDC);
31  ReleaseDC(0, hScreenDC);
32  ok(hDC != 0, "CreateCompatibleDC failed, skipping tests\n");
33  if (!hDC) return;
34 
35  // Select the DC_PEN and check if the pen returned by a new call is DC_PEN
38 
39  // Test an incorrect color, yes windows sets the color!
40  SetDCPenColor(hDC, 0x21123456);
41  ok(SetDCPenColor(hDC, RGB(0,0,0)) == 0x21123456, "\n");
42 
43  // Test CLR_INVALID, it sets CLR_INVALID!
45  ok(SetDCPenColor(hDC, RGB(0,0,0)) == CLR_INVALID, "\n");
46 
47  hbmp = CreateBitmap(10, 10, 1, 32, NULL);
48  ok(hbmp != 0, "CreateBitmap failed, skipping tests\n");
49  if (!hbmp) return;
51 #if 0 // this only works on 32 bpp screen resolution
52  ok(hbmpOld != NULL, "\n");
54  SetDCPenColor(hDC, 0x123456);
55  MoveToEx(hDC, 0, 0, NULL);
56  LineTo(hDC, 10, 0);
57  ok(GetPixel(hDC, 5, 0) == 0x123456, "\n");
58 #endif
59 
60  // Delete the DC
62  DeleteDC(hDC);
63 }
64 
66 {
68 }
69 
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
START_TEST(SetDCPenColor)
Definition: SetDCPenColor.c:65
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
#define CLR_INVALID
Definition: wingdi.h:882
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
HANDLE hbmpOld
Definition: magnifier.c:54
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
HBITMAP hbmp
#define RGB(r, g, b)
Definition: wingdi.h:2935
void Test_SetDCPenColor()
Definition: SetDCPenColor.c:10
#define SetLastError(x)
Definition: compat.h:409
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI DeleteDC(_In_ HDC)
#define BLACK_PEN
Definition: wingdi.h:902
#define ok(value,...)
Definition: atltest.h:57
static HBITMAP
Definition: button.c:44
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:917
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)