ReactOS 0.4.15-dev-7953-g1f49173
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);
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);
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);
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);
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);
77 /*Cleanup */
78 SelectObject(hdc, hOldBmp);
81 DeleteObject(hbmp1);
82 DeleteObject(hbmp2);
83
84}
HDC hdc2
Definition: SelectObject.c:10
#define NULL
Definition: types.h:112
pKey DeleteObject()
#define TEST(x)
Definition: precomp.h:20
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HINSTANCE hinst
Definition: edit.c:551
static HDC
Definition: imagelist.c:92
__kernel_entry W32KAPI BOOL APIENTRY NtGdiRestoreDC(_In_ HDC hdc, _In_ INT iLevel)
__kernel_entry W32KAPI INT APIENTRY NtGdiSaveDC(_In_ HDC hdc)
#define L(x)
Definition: ntvdm.h:50
#define OBJ_BITMAP
Definition: objidl.idl:1415
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
#define GetModuleHandle
Definition: winbase.h:3827
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HDC WINAPI CreateICW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ const DEVMODEW *)
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
BOOL WINAPI DestroyWindow(_In_ HWND)