ReactOS 0.4.16-dev-136-g52192f1
CreateCompatibleDC.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 CreateCompatibleDC
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8#include "precomp.h"
9
11{
12 HDC hdcScreen, hOldDC, hdc, hdc2;
13 HPEN hOldPen;
15
16 /* Get screen DC */
17 hdcScreen = GetDC(NULL);
18
19 /* Test NULL DC handle */
22 ok(hdc != NULL, "CreateCompatibleDC(NULL) failed\n");
23 ok(GetLastError() == ERROR_SUCCESS, "GetLastError() == %ld\n", GetLastError());
24 if(hdc) DeleteDC(hdc);
25
26 /* Test invalid DC handle */
28 hdc = CreateCompatibleDC((HDC)0x123456);
29 ok(hdc == NULL, "Expected NULL, got %p\n", hdc);
30 ok(GetLastError() == ERROR_SUCCESS, "GetLastError() == %ld\n", GetLastError());
31 if(hdc) DeleteDC(hdc);
32
33 hdc = CreateCompatibleDC(hdcScreen);
34 ok(hdc != NULL, "CreateCompatibleDC failed\n");
35
36 // Test if first selected pen is BLACK_PEN (? or same as screen DC's pen?)
37 hOldPen = SelectObject(hdc, GetStockObject(DC_PEN));
38 ok (hOldPen == GetStockObject(BLACK_PEN), "hOldPen == %p\n", hOldPen);
40 ok (hOldPen == GetStockObject(DC_PEN), "hOldPen == %p\n", hOldPen);
41
42 /* Test for the starting Color == RGB(0,0,0) */
43 color = SetDCPenColor(hdc, RGB(1,2,3));
44 ok(color == RGB(0,0,0), "color == %lx\n", color);
45
46 /* Check for reuse counter */
47 hOldDC = hdc;
49 hdc = CreateCompatibleDC(hdcScreen);
50 hdc2 = CreateCompatibleDC(hOldDC);
51 ok(hdc2 == NULL, "Expected NULL, got %p\n", hdc);
52 if (hdc2 != NULL) DeleteDC(hdc2);
53
54 /* Check map mode */
55 hdc = CreateCompatibleDC(hdcScreen);
58 ok(GetMapMode(hdc2) == MM_TEXT, "GetMapMode(hdc2)==%d\n", GetMapMode(hdc2));
59
60 /* cleanup */
62
63 ReleaseDC(NULL, hdcScreen);
64}
65
67{
69}
70
void Test_CreateCompatibleDC()
HDC hdc2
Definition: SelectObject.c:10
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define SetLastError(x)
Definition: compat.h:752
#define RGB(r, g, b)
Definition: precomp.h:71
GLuint color
Definition: glext.h:6243
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:941
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD COLORREF
Definition: windef.h:300
int WINAPI SetMapMode(_In_ HDC, _In_ int)
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI GetMapMode(_In_ HDC)
Definition: coord.c:114
#define BLACK_PEN
Definition: wingdi.h:903
#define MM_ISOTROPIC
Definition: wingdi.h:870
#define MM_TEXT
Definition: wingdi.h:873
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)