ReactOS 0.4.15-dev-8241-g63935f8
NtGdiDeleteObjectApp.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 NtGdiDeleteObjectApp
5 * PROGRAMMERS:
6 */
7
8#include "../win32nt.h"
9
11{
12 HDC hdc;
14 HBRUSH hbrush;
15 HPEN hpen;
16
17 /* Try to delete 0 */
18 SetLastError(0);
21
22 /* Try to delete something with a stockbit */
23 SetLastError(0);
26
27 /* Delete a compatible DC */
28 SetLastError(0);
34
35#ifdef _WIN64
36 /* Test upper 32 bits */
37 SetLastError(0);
38 hdc = (HDC)((ULONG64)CreateCompatibleDC(NULL) | 0xFFFFFFFF00000000ULL);
43
44 SetLastError(0);
45 hdc = (HDC)((ULONG64)CreateCompatibleDC(NULL) | 0x537F9F2F00000000ULL);
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");
63
64 /* Once more */
65 SetLastError(0);
66 hdc = GetDC(0);
68 ok(NtGdiDeleteObjectApp(hdc) != 0, "NtGdiDeleteObjectApp(hdc) was zero.\n");
73 /* Make sure */
75
76
77 /* Delete a brush */
78 SetLastError(0);
79 hbrush = CreateSolidBrush(0x123456);
84
85 /* Try to delete a stock brush */
86 SetLastError(0);
92
93 /* Delete a bitmap */
94 SetLastError(0);
95 hbmp = CreateBitmap(10, 10, 1, 1, NULL);
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);
136 ok(NtGdiSelectBrush(hdc, hbrush) != NULL, "NtGdiSelectBrush(hdc, hbrush) was NULL.\n");
137
139 ok_long(GetLastError(), 0);
141}
static HBRUSH hbrush
static HPEN hpen
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define ok_ptr(expression, result)
Definition: atltest.h:108
HBITMAP hbmp
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define GDI_HANDLE_STOCK_MASK
Definition: gdi.h:19
BOOL GdiIsHandleValid(_In_ HGDIOBJ hobj)
Definition: gditools.c:29
DWORD_PTR NTAPI NtUserCallOneParam(DWORD_PTR Param, DWORD Routine)
Definition: simplecall.c:153
@ ONEPARAM_ROUTINE_RELEASEDC
Definition: ntuser.h:1590
unsigned __int64 ULONG64
Definition: imports.h:198
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
__kernel_entry W32KAPI HBRUSH APIENTRY NtGdiSelectBrush(_In_ HDC hdc, _In_ HBRUSH hbrush)
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiSelectBitmap(_In_ HDC hdc, _In_ HBITMAP hbm)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDeleteObjectApp(_In_ HANDLE hobj)
#define DEFAULT_BITMAP
Definition: ntgdityp.h:195
uint32_t DWORD_PTR
Definition: typedefs.h:65
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateDC
Definition: wingdi.h:4441
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define WHITE_PEN
Definition: wingdi.h:905
#define BLACK_BRUSH
Definition: wingdi.h:896
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HDC WINAPI GetDC(_In_opt_ HWND)