ReactOS  0.4.15-dev-3456-g4a17d4b
NtGdiDeleteObjectApp.c File Reference
#include <win32nt.h>
Include dependency graph for NtGdiDeleteObjectApp.c:

Go to the source code of this file.

Functions

 START_TEST (NtGdiDeleteObjectApp)
 

Function Documentation

◆ START_TEST()

START_TEST ( NtGdiDeleteObjectApp  )

Definition at line 10 of file NtGdiDeleteObjectApp.c.

11 {
12  HDC hdc;
13  HBITMAP hbmp;
14  HBRUSH hbrush;
15  HPEN hpen;
16 
17  /* Try to delete 0 */
18  SetLastError(0);
20  ok_long(GetLastError(), 0);
21 
22  /* Try to delete something with a stockbit */
23  SetLastError(0);
25  ok_long(GetLastError(), 0);
26 
27  /* Delete a compatible DC */
28  SetLastError(0);
32  ok_long(GetLastError(), 0);
34 
35 #ifdef _WIN64
36  /* Test upper 32 bits */
37  SetLastError(0);
38  hdc = (HDC)((ULONG64)CreateCompatibleDC(NULL) | 0xFFFFFFFF00000000ULL);
41  ok_long(GetLastError(), 0);
43 
44  SetLastError(0);
45  hdc = (HDC)((ULONG64)CreateCompatibleDC(NULL) | 0x537F9F2F00000000ULL);
48  ok_long(GetLastError(), 0);
50 #endif
51 
52  /* Delete a display DC */
53  SetLastError(0);
54  hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
56  ok((hpen=SelectObject(hdc, GetStockObject(WHITE_PEN))) != NULL, "hpen was NULL.\n");
58  ok(NtGdiDeleteObjectApp(hdc) != 0, "NtGdiDeleteObjectApp(hdc) was zero.\n");
59  ok_long(GetLastError(), 0);
63 
64  /* Once more */
65  SetLastError(0);
66  hdc = GetDC(0);
68  ok(NtGdiDeleteObjectApp(hdc) != 0, "NtGdiDeleteObjectApp(hdc) was zero.\n");
69  ok_long(GetLastError(), 0);
73  /* Make sure */
75 
76 
77  /* Delete a brush */
78  SetLastError(0);
79  hbrush = CreateSolidBrush(0x123456);
82  ok_long(GetLastError(), 0);
84 
85  /* Try to delete a stock brush */
86  SetLastError(0);
90  ok_long(GetLastError(), 0);
92 
93  /* Delete a bitmap */
94  SetLastError(0);
95  hbmp = CreateBitmap(10, 10, 1, 1, NULL);
98  ok_long(GetLastError(), 0);
100 
101  /* Create a DC for further use */
103  ok(hdc != NULL, "hdc was NULL.\n");
104 
105  /* Try to delete a brush that is selected into a DC */
106  SetLastError(0);
107  hbrush = CreateSolidBrush(0x123456);
109  ok(NtGdiSelectBrush(hdc, hbrush) != NULL, "NtGdiSelectBrush(hdc, hbrush) was NULL.\n");
111  ok_long(GetLastError(), 0);
113 
114  /* Try to delete a bitmap that is selected into a DC */
115  SetLastError(0);
116  hbmp = CreateBitmap(10, 10, 1, 1, NULL);
118  ok(NtGdiSelectBitmap(hdc, hbmp) != NULL, "NtGdiSelectBitmap(hdc, hbmp) was NULL.\n");
119 
121  ok_long(GetLastError(), 0);
123 
124  /* Bitmap get's deleted as soon as we dereference it */
127 
129  ok_long(GetLastError(), 0);
131 
132  /* Try to delete a brush that is selected into a DC */
133  SetLastError(0);
134  hbrush = CreateSolidBrush(123);
136  ok(NtGdiSelectBrush(hdc, hbrush) != NULL, "NtGdiSelectBrush(hdc, hbrush) was NULL.\n");
137 
139  ok_long(GetLastError(), 0);
141 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static HBRUSH hbrush
HDC WINAPI GetDC(_In_opt_ HWND)
#define WHITE_PEN
Definition: wingdi.h:905
BOOL GdiIsHandleValid(_In_ HGDIOBJ hobj)
Definition: gditools.c:29
static HDC
Definition: imagelist.c:92
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiSelectBitmap(_In_ HDC hdc, _In_ HBITMAP hbm)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
DWORD_PTR NTAPI NtUserCallOneParam(DWORD_PTR Param, DWORD Routine)
Definition: simplecall.c:145
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static HPEN hpen
#define ok_ptr(expression, result)
Definition: atltest.h:108
#define ok_long(expression, result)
Definition: atltest.h:133
__kernel_entry W32KAPI HBRUSH APIENTRY NtGdiSelectBrush(_In_ HDC hdc, _In_ HBRUSH hbrush)
#define ok_int(expression, result)
Definition: atltest.h:134
#define DEFAULT_BITMAP
Definition: ntgdityp.h:195
#define ULL(a, b)
Definition: format_msg.c:27
#define BLACK_BRUSH
Definition: wingdi.h:896
HBITMAP hbmp
#define SetLastError(x)
Definition: compat.h:611
unsigned __int64 ULONG64
Definition: imports.h:198
HDC hdc
Definition: main.c:9
uint32_t DWORD_PTR
Definition: typedefs.h:65
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDeleteObjectApp(_In_ HANDLE hobj)
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define CreateDC
Definition: wingdi.h:4441
static HBITMAP
Definition: button.c:44
#define GDI_HANDLE_STOCK_MASK
Definition: gdi.h:19
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)