ReactOS  0.4.14-dev-376-gaedba84
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;
48  DeleteDC(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 */
61  DeleteDC(hdc);
62 
63  ReleaseDC(NULL, hdcScreen);
64 }
65 
67 {
69 }
70 
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define MM_ISOTROPIC
Definition: wingdi.h:869
#define ERROR_SUCCESS
Definition: deptool.c:10
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HDC hdc2
Definition: SelectObject.c:10
GLuint color
Definition: glext.h:6243
int WINAPI SetMapMode(_In_ HDC, _In_ int)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
void Test_CreateCompatibleDC()
START_TEST(CreateCompatibleDC)
DWORD COLORREF
Definition: windef.h:285
#define RGB(r, g, b)
Definition: wingdi.h:2935
#define SetLastError(x)
Definition: compat.h:417
HDC hdc
Definition: main.c:9
int WINAPI GetMapMode(_In_ HDC)
Definition: coord.c:114
BOOL WINAPI DeleteDC(_In_ HDC)
#define BLACK_PEN
Definition: wingdi.h:902
#define ok(value,...)
Definition: atltest.h:57
#define MM_TEXT
Definition: wingdi.h:872
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:917