ReactOS  0.4.11-dev-721-g95bc44e
NtGdiRestoreDC.c File Reference
#include <win32nt.h>
Include dependency graph for NtGdiRestoreDC.c:

Go to the source code of this file.

Functions

static void SetSpecialDCState (HDC hdc)
 
static void SetSpecialDCState2 (HDC hdc)
 
static void Test_IsSpecialState (HDC hdc, BOOL bMemDC)
 
static void Test_SaveRestore (HDC hdc, BOOL bMemDC)
 
 START_TEST (NtGdiRestoreDC)
 

Variables

static HBRUSH hbrush
 
static HBITMAP hbitmap
 
static HPEN hpen
 
static HFONT hfont
 
static HRGN hrgn
 
static HRGN hrgn2
 

Function Documentation

static void SetSpecialDCState ( HDC  hdc)
static

Definition at line 18 of file NtGdiRestoreDC.c.

Referenced by Test_SaveRestore().

19 {
20  /* Select spcial Objects */
26 
27  /* Colors */
28  SetDCBrushColor(hdc, RGB(12,34,56));
29  SetDCPenColor(hdc, RGB(23,34,45));
30 
31  /* Coordinates */
34  SetWindowOrgEx(hdc, 12, 34, NULL);
35  SetViewportOrgEx(hdc, 56, 78, NULL);
36  SetWindowExtEx(hdc, 123, 456, NULL);
37  SetViewportExtEx(hdc, 234, 567, NULL);
38 
39 
40 
41 }
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:648
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
static HBRUSH hbrush
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
static HPEN hpen
COLORREF WINAPI SetDCBrushColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:881
int WINAPI SetMapMode(_In_ HDC, _In_ int)
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
static HFONT hfont
#define RGB(r, g, b)
Definition: wingdi.h:2917
static HRGN hrgn
#define MM_ANISOTROPIC
Definition: wingdi.h:865
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:526
static HBITMAP hbitmap
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:917
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:462
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1202
#define GM_ADVANCED
Definition: wingdi.h:863
static void SetSpecialDCState2 ( HDC  hdc)
static

Definition at line 45 of file NtGdiRestoreDC.c.

Referenced by Test_SaveRestore().

46 {
47  /* Select spcial Objects */
48  SelectObject(hdc, GetStockObject(DC_BRUSH));
53 
54  /* Colors */
55  SetDCBrushColor(hdc, RGB(65,43,21));
56  SetDCPenColor(hdc, RGB(54,43,32));
57 
58  /* Coordinates */
61  SetWindowOrgEx(hdc, 43, 21, NULL);
62  SetViewportOrgEx(hdc, 87, 65, NULL);
63  SetWindowExtEx(hdc, 654, 321, NULL);
64  SetViewportExtEx(hdc, 765, 432, NULL);
65 
66 
67 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define MM_ISOTROPIC
Definition: wingdi.h:868
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:648
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
static HRGN hrgn2
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
COLORREF WINAPI SetDCBrushColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:881
int WINAPI SetMapMode(_In_ HDC, _In_ int)
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
#define DEFAULT_BITMAP
Definition: ntgdityp.h:192
#define RGB(r, g, b)
Definition: wingdi.h:2917
#define DEFAULT_GUI_FONT
Definition: wingdi.h:907
#define GM_COMPATIBLE
Definition: wingdi.h:862
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:526
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:917
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:462
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1202
START_TEST ( NtGdiRestoreDC  )

Definition at line 143 of file NtGdiRestoreDC.c.

144 {
145  HDC hdc;
146 
147  hdc = CreateCompatibleDC(0);
148  ASSERT(GdiIsHandleValid(hdc));
149 
150  SetLastError(0);
151  TEST(NtGdiRestoreDC(0, -10) == 0);
153 
154  SetLastError(0);
155  TEST(NtGdiRestoreDC(hdc, 0) == 0);
157 
158  SetLastError(0);
159  TEST(NtGdiRestoreDC(hdc, 1) == 0);
161 
162  /* Initialize objects */
163  hbrush = CreateSolidBrush(12345);
165  hpen = CreatePen(PS_SOLID, 4, RGB(10,12,32));
167  hbitmap = CreateBitmap(10, 10, 1, 1, NULL);
169  hfont = CreateFont(10, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET,
171  DEFAULT_PITCH, "Arial");
173  hrgn = CreateRectRgn(12, 14, 14, 17);
175  hrgn2 = CreateRectRgn(1, 1, 2, 2);
177 
178  /* Test mem dc */
179  Test_SaveRestore(hdc, TRUE);
180  DeleteDC(hdc);
181 
182  /* Test screen DC */
183  hdc = GetDC(0);
184  ASSERT(GdiIsHandleValid(hdc));
185  Test_SaveRestore(hdc, FALSE);
186  ReleaseDC(0, hdc);
187 
188  /* Test info dc */
189  hdc = CreateICW(L"DISPLAY", NULL, NULL, NULL);
190  ASSERT(GdiIsHandleValid(hdc));
191  Test_SaveRestore(hdc, FALSE);
192  DeleteDC(hdc);
193 
194 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define HDC
Definition: msvc.h:22
#define TRUE
Definition: types.h:120
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
static HBRUSH hbrush
#define DEFAULT_QUALITY
Definition: wingdi.h:434
HDC WINAPI GetDC(_In_opt_ HWND)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
static HRGN hrgn2
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOL GdiIsHandleValid(_In_ HGDIOBJ hobj)
Definition: gditools.c:29
__kernel_entry W32KAPI BOOL APIENTRY NtGdiRestoreDC(_In_ HDC hdc, _In_ INT iLevel)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static HPEN hpen
#define PS_SOLID
Definition: wingdi.h:584
#define FALSE
Definition: types.h:117
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:424
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define CreateFont
Definition: wingdi.h:4420
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
static HFONT hfont
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define DEFAULT_PITCH
Definition: wingdi.h:441
#define TEST(x)
Definition: precomp.h:20
#define RGB(r, g, b)
Definition: wingdi.h:2917
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:413
#define SetLastError(x)
Definition: compat.h:409
static HRGN hrgn
static const WCHAR L[]
Definition: oid.c:1087
static void Test_SaveRestore(HDC hdc, BOOL bMemDC)
BOOL WINAPI DeleteDC(_In_ HDC)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HDC WINAPI CreateICW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ const DEVMODEW *)
#define FW_NORMAL
Definition: wingdi.h:371
static HBITMAP hbitmap
#define ANSI_CHARSET
Definition: wingdi.h:381
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
static void Test_IsSpecialState ( HDC  hdc,
BOOL  bMemDC 
)
static

Definition at line 71 of file NtGdiRestoreDC.c.

Referenced by Test_SaveRestore().

72 {
73  POINT pt;
74  SIZE sz;
75 
76  /* Test Objects */
77  TEST(SelectObject(hdc, GetStockObject(DC_BRUSH)) == hbrush);
78  TEST(SelectObject(hdc, GetStockObject(DC_PEN)) == hpen);
80  if (bMemDC)
81  {
83  TEST(SelectObject(hdc, hrgn2) == (PVOID)1);
84  }
85  else
86  {
88  TEST(SelectObject(hdc, hrgn2) == (PVOID)2);
89  }
90 
91  /* Test colors */
92  TEST(GetDCBrushColor(hdc) == RGB(12,34,56));
93  TEST(GetDCPenColor(hdc) == RGB(23,34,45));
94 
95  /* Test coordinates */
98  GetWindowOrgEx(hdc, &pt);
99  TEST(pt.x == 12);
100  TEST(pt.y == 34);
101  GetViewportOrgEx(hdc, &pt);
102  TEST(pt.x == 56);
103  TEST(pt.y == 78);
104  GetWindowExtEx(hdc, &sz);
105  TESTX(sz.cx == 123, "sz.cx == %ld\n", sz.cx);
106  TESTX(sz.cy == 456, "sz.cy == %ld\n", sz.cy);
107  GetViewportExtEx(hdc, &sz);
108  TEST(sz.cx == 234);
109  TEST(sz.cy == 567);
110 
111 
112 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
DWORD *typedef PVOID
Definition: winlogon.h:61
static HBRUSH hbrush
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
BOOL WINAPI GetWindowOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:436
#define pt(x, y)
Definition: drawing.c:79
static HRGN hrgn2
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
static HPEN hpen
#define TESTX
Definition: win32nt.h:34
HDC hdc
Definition: msvc.h:53
LONG cx
Definition: windef.h:324
#define DEFAULT_BITMAP
Definition: ntgdityp.h:192
static HFONT hfont
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:348
#define TEST(x)
Definition: precomp.h:20
int WINAPI GetGraphicsMode(_In_ HDC)
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:408
#define RGB(r, g, b)
Definition: wingdi.h:2917
BOOL WINAPI GetViewportOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:380
#define DEFAULT_GUI_FONT
Definition: wingdi.h:907
#define MM_ANISOTROPIC
Definition: wingdi.h:865
int WINAPI GetMapMode(_In_ HDC)
Definition: coord.c:114
COLORREF WINAPI GetDCBrushColor(_In_ HDC hdc)
Definition: dc.c:839
COLORREF WINAPI GetDCPenColor(_In_ HDC hdc)
Definition: dc.c:860
static HBITMAP hbitmap
LONG cy
Definition: windef.h:325
#define GM_ADVANCED
Definition: wingdi.h:863
static void Test_SaveRestore ( HDC  hdc,
BOOL  bMemDC 
)
static

Definition at line 117 of file NtGdiRestoreDC.c.

Referenced by START_TEST().

118 {
120  NtGdiSaveDC(hdc);
122 
123  SetLastError(0);
124  TEST(NtGdiRestoreDC(hdc, 2) == 0);
126 
127  SetLastError(0);
128  TEST(NtGdiRestoreDC(hdc, 0) == 0);
130 
131  SetLastError(0);
132  TEST(NtGdiRestoreDC(hdc, -2) == 0);
134 
135  SetLastError(0);
136  TEST(NtGdiRestoreDC(hdc, 1) == 1);
137  TEST(GetLastError() == 0);
138 
139  Test_IsSpecialState(hdc, bMemDC);
140 }
static void Test_IsSpecialState(HDC hdc, BOOL bMemDC)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
__kernel_entry W32KAPI BOOL APIENTRY NtGdiRestoreDC(_In_ HDC hdc, _In_ INT iLevel)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
__kernel_entry W32KAPI INT APIENTRY NtGdiSaveDC(_In_ HDC hdc)
static void SetSpecialDCState(HDC hdc)
HDC hdc
Definition: msvc.h:53
#define TEST(x)
Definition: precomp.h:20
#define SetLastError(x)
Definition: compat.h:409
static void SetSpecialDCState2(HDC hdc)

Variable Documentation

HFONT hfont
static

Definition at line 13 of file NtGdiRestoreDC.c.

Referenced by add_hfontitem(), check_vertical_font(), check_vertical_metrics(), create_fixed_pitch_font_proc(), create_font(), create_font_proc(), default_page_paint_hook(), find_installed_font(), GDI32_GdipDrawDriverString(), gdi_get_font_metrics(), GdiConvertFont(), GdiGetLocalFont(), GdipAddPathString(), GdipCreateFont(), GdipCreateFontFromDC(), GdipCreateFontFromLogfontW(), GdipMeasureDriverString(), GdiSelectFont(), get_current_font_height(), get_font_dpi(), get_font_fsselection(), get_glyph_indices(), get_text_metr_size(), get_tmheight(), MainWndProc(), OleCreatePropertyFrameIndirect(), SetSpecialDCState(), SOFTWARE_GdipDrawDriverString(), START_TEST(), test_bitmap_font(), test_bitmap_font_metrics(), test_button_messages(), test_CreateFontIndirect(), test_CreateFontIndirectEx(), test_east_asian_font_selection(), test_fake_bold_font(), test_font_substitution(), test_fontsize(), test_fstype_fixup(), test_fullname(), test_fullname2_helper(), test_GdiGetCodePage(), test_GetCharABCWidths(), test_GetCharWidth32(), test_GetCharWidthI(), test_GetCurrentObject(), test_GetFontUnicodeRanges(), test_GetGlyphIndices(), test_GetGlyphOutline(), test_GetGlyphOutline_empty_contour(), test_GetGlyphOutline_metric_clipping(), test_GetKerningPairs(), test_GetOutlineTextMetrics(), test_height(), test_hfont_lifetime(), test_ifont_size(), Test_IsSpecialState(), test_logfont(), test_margins_font_change(), test_margins_usefontinfo(), test_max_height(), test_negative_width(), test_nonexistent_font(), test_oemcharset(), test_orientation(), test_outline_font(), test_RealizationInfo(), test_ScriptCacheGetHeight(), test_ScriptShapeOpenType(), test_SetTextJustification(), test_stock_fonts(), test_text_extents(), test_text_metrics(), and HyperlinkCtrl::WndProc().

HRGN hrgn
static

Definition at line 14 of file NtGdiRestoreDC.c.

Referenced by SetSpecialDCState(), and START_TEST().