ReactOS  0.4.14-dev-376-gaedba84
NtGdiSaveDC.c File Reference
#include <win32nt.h>
Include dependency graph for NtGdiSaveDC.c:

Go to the source code of this file.

Functions

 START_TEST (NtGdiSaveDC)
 

Function Documentation

◆ START_TEST()

START_TEST ( NtGdiSaveDC  )

Definition at line 10 of file NtGdiSaveDC.c.

11 {
13  HDC hdc, hdc2;
14  HWND hwnd;
15  HBITMAP hbmp1, hbmp2, hOldBmp;
16 
17  /* Test 0 hdc */
18  TEST(NtGdiSaveDC(0) == 0);
19 
20  /* Test info dc */
21  hdc = CreateICW(L"DISPLAY",NULL,NULL,NULL);
22  TEST(hdc != NULL);
23  TEST(NtGdiSaveDC(hdc) == 1);
24  TEST(NtGdiSaveDC(hdc) == 2);
25  DeleteDC(hdc);
26 
27  /* Test display dc */
28  hdc = GetDC(0);
29  TEST(hdc != NULL);
30  TEST(NtGdiSaveDC(hdc) == 1);
31  TEST(NtGdiSaveDC(hdc) == 2);
32  ReleaseDC(0, hdc);
33 
34  /* Test a mem DC */
36  TEST(hdc != NULL);
37  TEST(NtGdiSaveDC(hdc) == 1);
38  TEST(NtGdiSaveDC(hdc) == 2);
39  DeleteDC(hdc);
40 
41  /* Create a window */
42  hwnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
43  10, 10, 100, 100,
44  NULL, NULL, hinst, 0);
45  hdc = GetDC(hwnd);
46  TEST(hdc != NULL);
47  TEST(NtGdiSaveDC(hdc) == 1);
48  NtGdiRestoreDC(hdc, 1);
49  ReleaseDC(hwnd, hdc);
51 
52  /* test behaviour when a bitmap is selected */
53  hbmp1 = CreateBitmap(2, 2, 1, 1, NULL);
54  TEST(hbmp1 != NULL);
55  hbmp2 = CreateBitmap(2, 2, 1, 1, NULL);
56  TEST(hbmp2 != NULL);
58  TEST(hdc != NULL);
60  TEST(hdc2 != NULL);
61  hOldBmp = SelectObject(hdc, hbmp1);
62  TEST(hOldBmp != NULL);
63  TEST(NtGdiSaveDC(hdc) == 1);
64  TEST(SelectObject(hdc, hbmp2) == hbmp1);
65  TEST(SelectObject(hdc2, hbmp1) == NULL);
66  SelectObject(hdc, hOldBmp);
67  NtGdiRestoreDC(hdc, 1);
68  TEST(GetCurrentObject(hdc, OBJ_BITMAP) == hbmp1);
69  /* Again, just to be sure */
70  TEST(NtGdiSaveDC(hdc) == 1);
71  TEST(NtGdiSaveDC(hdc) == 2);
72  TEST(SelectObject(hdc, hbmp2) == hbmp1);
73  TEST(SelectObject(hdc2, hbmp1) == NULL);
74  SelectObject(hdc, hOldBmp);
75  NtGdiRestoreDC(hdc, 2);
76  TEST(GetCurrentObject(hdc, OBJ_BITMAP) == hbmp1);
77  /*Cleanup */
78  SelectObject(hdc, hOldBmp);
79  DeleteDC(hdc);
80  DeleteDC(hdc2);
81  DeleteObject(hbmp1);
82  DeleteObject(hbmp2);
83 
84 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
__kernel_entry W32KAPI BOOL APIENTRY NtGdiRestoreDC(_In_ HDC hdc, _In_ INT iLevel)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4217
HDC hdc2
Definition: SelectObject.c:10
__kernel_entry W32KAPI INT APIENTRY NtGdiSaveDC(_In_ HDC hdc)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
#define TEST(x)
Definition: precomp.h:20
static const WCHAR L[]
Definition: oid.c:1250
HDC hdc
Definition: main.c:9
#define GetModuleHandle
Definition: winbase.h:3651
BOOL WINAPI DeleteDC(_In_ HDC)
HDC WINAPI CreateICW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ const DEVMODEW *)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
static HINSTANCE hinst
Definition: edit.c:551
static HBITMAP
Definition: button.c:44
#define WS_VISIBLE
Definition: pedump.c:620
#define OBJ_BITMAP
Definition: objidl.idl:1415
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)