0eaff6ef06851e2902e19bc40217e3d7af6cf43e
[reactos.git] / rostests / apitests / gdi32 / GetObject.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for GetObject
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8 #include <apitest.h>
9
10 #include <wingdi.h>
11 #include <winddi.h>
12 #include <winuser.h>
13 #include <include/ntgdityp.h>
14 #include <include/ntgdihdl.h>
15
16 void
17 Test_General(void)
18 {
19 struct
20 {
21 LOGBRUSH logbrush;
22 BYTE additional[600];
23 } TestStruct;
24 PLOGBRUSH plogbrush;
25 HBRUSH hBrush;
26 HPEN hpen;
27 INT ret;
28
29 /* Test null pointer and invalid handles */
30 SetLastError(ERROR_SUCCESS);
31 ok(GetObjectA(0, 0, NULL) == 0, "\n");
32 ok(GetObjectA((HANDLE)-1, 0, NULL) == 0, "\n");
33
34 /* Test invalid habdles of different types */
35 ok(GetObjectA((HANDLE)0x00380000, 0, NULL) == 0, "\n");
36 ok(GetLastError() == ERROR_SUCCESS, "\n");
37 ok(GetObjectA((HANDLE)0x00380000, 10, &TestStruct) == 0, "\n");
38 ok(GetLastError() == ERROR_SUCCESS, "\n");
39 SetLastError(ERROR_SUCCESS);
40 ok(GetObjectA((HANDLE)0x00010000, 0, NULL) == 0, "\n");
41 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
42 SetLastError(ERROR_SUCCESS);
43 ok(GetObjectA((HANDLE)0x00020000, 0, NULL) == 0, "\n");
44 ok(GetLastError() == ERROR_SUCCESS, "\n");
45 SetLastError(ERROR_SUCCESS);
46 ok(GetObjectA((HANDLE)0x00030000, 0, NULL) == 0, "\n");
47 ok(GetLastError() == ERROR_SUCCESS, "\n");
48 SetLastError(ERROR_SUCCESS);
49 ok(GetObjectA((HANDLE)0x00040000, 0, NULL) == 0, "\n");
50 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
51 SetLastError(ERROR_SUCCESS);
52 ok(GetObjectA((HANDLE)0x00060000, 0, NULL) == 0, "\n");
53 ok(GetLastError() == ERROR_SUCCESS, "\n");
54 SetLastError(ERROR_SUCCESS);
55 ok(GetObjectA((HANDLE)0x00070000, 0, NULL) == 0, "\n");
56 ok(GetLastError() == ERROR_SUCCESS, "\n");
57 SetLastError(ERROR_SUCCESS);
58 ok(GetObjectA((HANDLE)0x000B0000, 0, NULL) == 0, "\n");
59 ok(GetLastError() == ERROR_SUCCESS, "\n");
60 SetLastError(ERROR_SUCCESS);
61 ok(GetObjectA((HANDLE)0x000C0000, 0, NULL) == 0, "\n");
62 ok(GetLastError() == ERROR_SUCCESS, "\n");
63 SetLastError(ERROR_SUCCESS);
64 ok(GetObjectA((HANDLE)0x000D0000, 0, NULL) == 0, "\n");
65 ok(GetLastError() == ERROR_SUCCESS, "\n");
66 SetLastError(ERROR_SUCCESS);
67 ok(GetObjectA((HANDLE)0x000E0000, 0, NULL) == 0, "\n");
68 ok(GetLastError() == ERROR_SUCCESS, "\n");
69 SetLastError(ERROR_SUCCESS);
70 ok(GetObjectA((HANDLE)0x000F0000, 0, NULL) == 0, "\n");
71 ok(GetLastError() == ERROR_SUCCESS, "\n");
72 SetLastError(ERROR_SUCCESS);
73 ok(GetObjectA((HANDLE)0x00110000, 0, NULL) == 0, "\n");
74 ok(GetLastError() == ERROR_SUCCESS, "\n");
75 SetLastError(ERROR_SUCCESS);
76 ok(GetObjectA((HANDLE)0x00120000, 0, NULL) == 0, "\n");
77 ok(GetLastError() == ERROR_SUCCESS, "\n");
78 SetLastError(ERROR_SUCCESS);
79 ok(GetObjectA((HANDLE)0x00130000, 0, NULL) == 0, "\n");
80 ok(GetLastError() == ERROR_SUCCESS, "\n");
81 SetLastError(ERROR_SUCCESS);
82 ok(GetObjectA((HANDLE)0x00140000, 0, NULL) == 0, "\n");
83 ok(GetLastError() == ERROR_SUCCESS, "\n");
84 SetLastError(ERROR_SUCCESS);
85 ok(GetObjectA((HANDLE)0x00150000, 0, NULL) == 0, "\n");
86 ok(GetLastError() == ERROR_SUCCESS, "\n");
87 SetLastError(ERROR_SUCCESS);
88 ok(GetObjectA((HANDLE)0x00160000, 0, NULL) == 0, "\n");
89 ok(GetLastError() == ERROR_SUCCESS, "\n");
90 SetLastError(ERROR_SUCCESS);
91 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n");
92 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
93 SetLastError(ERROR_SUCCESS);
94 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n");
95 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
96 SetLastError(ERROR_SUCCESS);
97 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0, "\n");
98 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
99 SetLastError(ERROR_SUCCESS);
100 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0, "\n");
101 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
102 SetLastError(ERROR_SUCCESS);
103 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n");
104 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
105 SetLastError(ERROR_SUCCESS);
106 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n");
107 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
108 SetLastError(ERROR_SUCCESS);
109 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0, "\n");
110 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
111 SetLastError(ERROR_SUCCESS);
112 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0, "\n");
113 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
114 SetLastError(ERROR_SUCCESS);
115 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0, "\n");
116 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
117 SetLastError(ERROR_SUCCESS);
118 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0, "\n");
119 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
120
121 /* Test need of alignment */
122 SetLastError(ERROR_SUCCESS);
123 hBrush = GetStockObject(WHITE_BRUSH);
124 plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush);
125 ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH), "\n");
126 plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 2);
127 ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH), "\n");
128 plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 1);
129 //ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == 0, "\n"); // fails on win7
130
131 /* Test invalid buffer */
132 SetLastError(0xbadbad00);
133 ok(GetObjectA(GetStockObject(WHITE_BRUSH), sizeof(LOGBRUSH), (PVOID)0xc0000000) == 0, "\n");
134 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
135 SetLastError(0xbadbad00);
136 ok(GetObjectW(GetStockObject(BLACK_PEN), sizeof(LOGPEN), (PVOID)0xc0000000) == 0, "\n");
137 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
138 SetLastError(0xbadbad00);
139 ok(GetObjectW(GetStockObject(21), sizeof(BITMAP), (PVOID)0xc0000000) == 0, "\n");
140 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
141 SetLastError(0xbadbad00);
142 ok(GetObjectW(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), (PVOID)0xc0000000) == 0, "\n");
143 ok(GetLastError() == 0xbadbad00, "wrong error: %ld\n", GetLastError());
144 SetLastError(ERROR_SUCCESS);
145 _SEH2_TRY
146 {
147 ret = GetObjectA(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), (PVOID)0xc0000000);
148 }
149 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
150 {
151 ret = -1;
152 }
153 _SEH2_END
154 ok(ret == -1, "should have got an exception\n");
155
156 ok(GetObjectW(GetStockObject(SYSTEM_FONT), 0x50000000, &TestStruct) == 356, "\n");
157 ok(GetObjectW(GetStockObject(WHITE_BRUSH), 0x50000000, &TestStruct) == sizeof(LOGBRUSH), "\n");
158
159
160 /* Test buffer size of 0 */
161 SetLastError(0xbadbad00);
162 hBrush = CreateSolidBrush(123);
163 ok(hBrush != NULL, "Failed to create brush\n");
164 ok_long(GetObjectA(hBrush, 0, &TestStruct), sizeof(LOGBRUSH));
165 ok_err(0xbadbad00);
166 DeleteObject(hBrush);
167 SetLastError(0xbadbad00);
168 hpen = CreatePen(PS_SOLID, 1, 123);
169 ok(hpen != NULL, "Failed to create pen\n");
170 ok_long(GetObjectA(hpen, 0, &TestStruct), 0);
171 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
172 SetLastError(0xbadbad00);
173 TestStruct.logbrush.lbStyle = BS_SOLID;
174 TestStruct.logbrush.lbColor = RGB(1,2,3);
175 TestStruct.logbrush.lbHatch = 0;
176 hpen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID, 1, &TestStruct.logbrush, 0, NULL);
177 ok(hpen != NULL, "Failed to create pen\n");
178 ok_long(GetObjectA(hpen, 0, &TestStruct), 0);
179 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
180 SetLastError(0xbadbad00);
181 ok(GetObjectW(GetStockObject(SYSTEM_FONT), 0, &TestStruct) == 0, "\n");
182 ok_err(0xbadbad00);
183 SetLastError(0xbadbad00);
184 ok(GetObjectW(GetStockObject(21), 0, &TestStruct) == 0, "\n");
185 ok_err(0xbadbad00);
186
187 }
188
189 void
190 Test_Bitmap(void)
191 {
192 HBITMAP hBitmap;
193 BITMAP bitmap;
194 DIBSECTION dibsection;
195 BYTE bData[100] = {0};
196 BYTE Buffer[100] = {48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,0};
197
198 FillMemory(&bitmap, sizeof(BITMAP), 0x77);
199 hBitmap = CreateBitmap(10,10,1,8,bData);
200 ok(hBitmap != 0, "CreateBitmap failed, skipping tests.\n");
201 if (!hBitmap) return;
202
203 SetLastError(ERROR_SUCCESS);
204 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP), "\n");
205 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP), "\n");
206 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAP), NULL) == sizeof(BITMAP), "\n");
207 ok(GetLastError() == ERROR_SUCCESS, "\n");
208 ok(GetObjectA(hBitmap, sizeof(DIBSECTION), NULL) == sizeof(BITMAP), "\n");
209 ok(GetObjectA(hBitmap, 0, NULL) == sizeof(BITMAP), "\n");
210 ok(GetObjectA((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
211 ok(GetObjectW((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
212 ok(GetLastError() == ERROR_SUCCESS, "\n");
213 ok(GetObjectA(hBitmap, 5, NULL) == sizeof(BITMAP), "\n");
214 ok(GetObjectA(hBitmap, -5, NULL) == sizeof(BITMAP), "\n");
215 ok(GetObjectA(hBitmap, 0, Buffer) == 0, "\n");
216 ok(GetObjectA(hBitmap, 5, Buffer) == 0, "\n");
217 ok(GetLastError() == ERROR_SUCCESS, "\n");
218 ok(GetObjectA(hBitmap, sizeof(BITMAP), &bitmap) == sizeof(BITMAP), "\n");
219 ok(GetObjectA(hBitmap, sizeof(BITMAP)+2, &bitmap) == sizeof(BITMAP), "\n");
220 ok(GetObjectA(hBitmap, sizeof(DIBSECTION), &dibsection) == sizeof(BITMAP), "\n");
221 ok(GetObjectA(hBitmap, -5, &bitmap) == sizeof(BITMAP), "\n");
222 ok(GetLastError() == ERROR_SUCCESS, "\n");
223 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAP), &bitmap) == 0, "\n");
224 ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError());
225
226 // todo: test invalid handle + buffer
227
228 DeleteObject(hBitmap);
229 }
230
231 void
232 Test_Dibsection(void)
233 {
234 BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 9, 1, 16, BI_RGB, 0, 10, 10, 0,0}};
235 HBITMAP hBitmap;
236 BITMAP bitmap;
237 DIBSECTION dibsection;
238 PVOID pData;
239 HDC hDC;
240
241 FillMemory(&dibsection, sizeof(DIBSECTION), 0x77);
242 hDC = GetDC(0);
243 hBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pData, NULL, 0);
244 ok(hBitmap != 0, "CreateDIBSection failed with %ld, skipping tests.\n", GetLastError());
245 if (!hBitmap) return;
246
247 ok(GetObjectA((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
248 ok(GetObjectW((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
249
250 SetLastError(ERROR_SUCCESS);
251 ok_long(GetObject(hBitmap, sizeof(DIBSECTION), NULL), sizeof(BITMAP));
252 ok_long(GetObject(hBitmap, 0, NULL), sizeof(BITMAP));
253 ok_long(GetObject(hBitmap, 5, NULL), sizeof(BITMAP));
254 ok_long(GetObject(hBitmap, -5, NULL), sizeof(BITMAP));
255 ok_long(GetObject(hBitmap, 0, &dibsection), 0);
256 ok_long(GetObject(hBitmap, 5, &dibsection), 0);
257 ok_long(GetObject(hBitmap, sizeof(BITMAP), &bitmap), sizeof(BITMAP));
258 ok_long(GetObject(hBitmap, sizeof(BITMAP)+2, &bitmap), sizeof(BITMAP));
259 ok_long(bitmap.bmType, 0);
260 ok_long(bitmap.bmWidth, 10);
261 ok_long(bitmap.bmHeight, 9);
262 ok_long(bitmap.bmWidthBytes, 20);
263 ok_long(bitmap.bmPlanes, 1);
264 ok_long(bitmap.bmBitsPixel, 16);
265 ok(bitmap.bmBits == pData, "\n");
266 ok_long(GetObject(hBitmap, sizeof(DIBSECTION), &dibsection), sizeof(DIBSECTION));
267 ok_long(GetObject(hBitmap, sizeof(DIBSECTION)+2, &dibsection), sizeof(DIBSECTION));
268 ok_long(GetObject(hBitmap, -5, &dibsection), sizeof(DIBSECTION));
269 ok_err(ERROR_SUCCESS);
270 DeleteObject(hBitmap);
271 ReleaseDC(0, hDC);
272 }
273
274 void
275 Test_Palette(void)
276 {
277 LOGPALETTE logpal;
278 HPALETTE hPalette;
279 WORD wPalette;
280
281 FillMemory(&wPalette, sizeof(WORD), 0x77);
282 logpal.palVersion = 0x0300;
283 logpal.palNumEntries = 1;
284 logpal.palPalEntry[0].peRed = 0;
285 logpal.palPalEntry[0].peGreen = 0;
286 logpal.palPalEntry[0].peBlue = 0;
287 logpal.palPalEntry[0].peFlags = PC_EXPLICIT;
288 hPalette = CreatePalette(&logpal);
289 ok(hPalette != 0, "CreatePalette failed, skipping tests.\n");
290 if (!hPalette) return;
291
292 ok(GetObjectA((HANDLE)((UINT_PTR)hPalette & 0x0000ffff), 0, NULL) == sizeof(WORD), "\n");
293 ok(GetObjectW((HANDLE)((UINT_PTR)hPalette & 0x0000ffff), 0, NULL) == sizeof(WORD), "\n");
294
295 SetLastError(ERROR_SUCCESS);
296 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD), "\n");
297 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD), "\n");
298 ok(GetObject(hPalette, sizeof(WORD), NULL) == sizeof(WORD), "\n");
299 ok(GetObject(hPalette, 0, NULL) == sizeof(WORD), "\n");
300 ok(GetObject(hPalette, 5, NULL) == sizeof(WORD), "\n");
301 ok(GetObject(hPalette, -5, NULL) == sizeof(WORD), "\n");
302 ok(GetObject(hPalette, sizeof(WORD), &wPalette) == sizeof(WORD), "\n");
303 ok(GetObject(hPalette, sizeof(WORD)+2, &wPalette) == sizeof(WORD), "\n");
304 ok(GetObject(hPalette, 0, &wPalette) == 0, "\n");
305 ok(GetObject(hPalette, 1, &wPalette) == 0, "\n");
306 ok(GetObject(hPalette, -1, &wPalette) == sizeof(WORD), "\n");
307 ok(GetLastError() == ERROR_SUCCESS, "\n");
308 DeleteObject(hPalette);
309 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, sizeof(WORD), &wPalette) == 0, "\n");
310 ok(GetLastError() == ERROR_SUCCESS, "\n");
311
312 }
313
314 void
315 Test_Brush(void)
316 {
317 LOGBRUSH logbrush;
318 HBRUSH hBrush;
319
320 FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
321 hBrush = CreateSolidBrush(RGB(1,2,3));
322 ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
323 if (!hBrush) return;
324
325 SetLastError(ERROR_SUCCESS);
326 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH), "\n");
327 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH), "\n");
328 ok(GetObject(hBrush, sizeof(WORD), NULL) == sizeof(LOGBRUSH), "\n");
329 ok(GetObject(hBrush, 0, NULL) == sizeof(LOGBRUSH), "\n");
330 ok(GetObject(hBrush, 5, NULL) == sizeof(LOGBRUSH), "\n");
331 ok(GetObject(hBrush, -5, NULL) == sizeof(LOGBRUSH), "\n");
332
333 //ok(GetObject(hBrush, 0, &logbrush) == 0, "\n"); fails on win7
334 ok(logbrush.lbStyle == 0x77777777, "\n");
335 ok(GetObject(hBrush, 5, &logbrush) == sizeof(LOGBRUSH), "\n");
336 ok(logbrush.lbStyle == 0, "\n");
337 ok(logbrush.lbColor == 0x77777701, "\n");
338
339 ok(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH), "\n");
340 ok(GetObject(hBrush, sizeof(LOGBRUSH) - 1, &logbrush) == sizeof(LOGBRUSH), "\n");
341 ok(GetObject(hBrush, 1, &logbrush) == sizeof(LOGBRUSH), "\n");
342 ok(GetObject(hBrush, sizeof(LOGBRUSH)+2, &logbrush) == sizeof(LOGBRUSH), "\n");
343 ok(GetObject(hBrush, -1, &logbrush) == sizeof(LOGBRUSH), "\n");
344 // TODO: test all members
345
346 ok(GetLastError() == ERROR_SUCCESS, "\n");
347 DeleteObject(hBrush);
348
349 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, sizeof(LOGBRUSH), &logbrush) == 0, "\n");
350 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
351 }
352
353 void
354 Test_DIBBrush(void)
355 {
356 struct
357 {
358 BITMAPINFOHEADER bmiHeader;
359 WORD wColors[4];
360 BYTE jBuffer[16];
361 } PackedDIB =
362 {
363 {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 4, 0},
364 {1, 7, 3, 1},
365 {0,1,2,3, 1,2,3,0, 2,3,0,1, 3,0,1,2},
366 };
367 LOGBRUSH logbrush;
368 HBRUSH hBrush;
369
370 /* Create a DIB brush */
371 hBrush = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
372 ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
373 if (!hBrush) return;
374
375 FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
376 SetLastError(ERROR_SUCCESS);
377
378 ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
379 ok_long(logbrush.lbStyle, BS_DIBPATTERN);
380 ok_long(logbrush.lbColor, 0);
381 ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);
382
383 ok_err(ERROR_SUCCESS);
384 DeleteObject(hBrush);
385
386
387 /* Create a DIB brush with undocumented iUsage 2 */
388 hBrush = CreateDIBPatternBrushPt(&PackedDIB, 2);
389 ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
390 if (!hBrush) return;
391
392 FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
393 SetLastError(ERROR_SUCCESS);
394
395 ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
396 ok_long(logbrush.lbStyle, BS_DIBPATTERN);
397 ok_long(logbrush.lbColor, 0);
398 ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);
399
400 ok_err(ERROR_SUCCESS);
401 DeleteObject(hBrush);
402
403 }
404
405 void
406 Test_Pen(void)
407 {
408 LOGPEN logpen;
409 HPEN hPen;
410
411 FillMemory(&logpen, sizeof(LOGPEN), 0x77);
412 hPen = CreatePen(PS_SOLID, 3, RGB(4,5,6));
413 ok(hPen != 0, "CreatePen failed, skipping tests.\n");
414 if (!hPen) return;
415 SetLastError(ERROR_SUCCESS);
416 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
417 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
418 ok(GetObject(hPen, sizeof(BITMAP), NULL) == sizeof(LOGPEN), "\n");
419 ok(GetObject(hPen, 0, NULL) == sizeof(LOGPEN), "\n");
420 ok(GetObject(hPen, 5, NULL) == sizeof(LOGPEN), "\n");
421 ok(GetObject(hPen, -5, NULL) == sizeof(LOGPEN), "\n");
422 ok(GetObject(hPen, sizeof(LOGPEN), &logpen) == sizeof(LOGPEN), "\n");
423 ok(GetObject(hPen, sizeof(LOGPEN)-1, &logpen) == 0, "\n");
424 ok(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN), "\n");
425 ok(GetObject(hPen, 0, &logpen) == 0, "\n");
426 ok(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN), "\n");
427 //ok(GetLastError() == ERROR_SUCCESS, "\n"); fails on win7
428
429 /* test if the fields are filled correctly */
430 ok(logpen.lopnStyle == PS_SOLID, "\n");
431
432 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, sizeof(LOGPEN), &logpen) == 0, "\n");
433 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
434
435 DeleteObject(hPen);
436 }
437
438 void
439 Test_ExtPen(void)
440 {
441 HPEN hPen;
442 EXTLOGPEN extlogpen;
443 LOGBRUSH logbrush;
444 DWORD dwStyles[17] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
445 struct
446 {
447 EXTLOGPEN extlogpen;
448 DWORD dwStyles[50];
449 } elpUserStyle;
450 int i;
451
452 SetLastError(ERROR_SUCCESS);
453 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
454 ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n");
455 SetLastError(ERROR_SUCCESS);
456 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
457 ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n");
458
459 FillMemory(&extlogpen, sizeof(EXTLOGPEN), 0x77);
460 logbrush.lbStyle = BS_SOLID;
461 logbrush.lbColor = RGB(1,2,3);
462 logbrush.lbHatch = 22;
463 hPen = ExtCreatePen(PS_GEOMETRIC | PS_DASH, 5, &logbrush, 0, NULL);
464
465 SetLastError(ERROR_SUCCESS);
466 ok(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN, "\n");
467 ok(GetObject(hPen, sizeof(EXTLOGPEN), NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
468 ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
469 ok(GetObject((HANDLE)GDI_HANDLE_GET_INDEX(hPen), 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
470 ok(GetObject(hPen, 5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
471 ok(GetObject(hPen, -5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
472 ok(GetLastError() == ERROR_SUCCESS, "\n");
473 ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
474 ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
475 SetLastError(0xbadbad00);
476 ok(GetObject(hPen, 0, &extlogpen) == 0, "\n");
477 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
478 SetLastError(ERROR_SUCCESS);
479 ok(GetObject(hPen, 4, &extlogpen) == 0, "\n");
480 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
481 SetLastError(ERROR_SUCCESS);
482 ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, &extlogpen) == 0, "\n");
483 ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
484 SetLastError(ERROR_SUCCESS);
485 ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 4, &extlogpen) == 0, "\n");
486 ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
487 SetLastError(ERROR_SUCCESS);
488 ok(GetObject(hPen, sizeof(EXTLOGPEN) - 5, &extlogpen) == 0, "\n");
489 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
490
491 /* Nothing should be filled */
492 ok(extlogpen.elpPenStyle == 0x77777777, "\n");
493 ok(extlogpen.elpWidth == 0x77777777, "\n");
494
495 ok(GetObject(hPen, sizeof(EXTLOGPEN), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
496 ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
497 ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD)-1, &extlogpen) == 0, "\n");
498 ok(GetObject(hPen, sizeof(EXTLOGPEN)+2, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
499 ok(GetObject(hPen, -5, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
500
501 /* test if the fields are filled correctly */
502 ok(extlogpen.elpPenStyle == (PS_GEOMETRIC | PS_DASH), "\n");
503 ok(extlogpen.elpWidth == 5, "\n");
504 ok(extlogpen.elpBrushStyle == 0, "\n");
505 ok(extlogpen.elpColor == RGB(1,2,3), "\n");
506 ok(extlogpen.elpHatch == 22, "\n");
507 ok(extlogpen.elpNumEntries == 0, "\n");
508 DeleteObject(hPen);
509
510 /* A maximum of 16 Styles is allowed */
511 hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles);
512 ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n");
513 ok(GetObject(hPen, sizeof(EXTLOGPEN) + 15*sizeof(DWORD), &elpUserStyle) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n");
514 for (i = 0; i <= 15; i++)
515 ok(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[i] == i, "%d\n", i);
516 DeleteObject(hPen);
517 }
518
519 void
520 Test_Font(void)
521 {
522 HFONT hFont;
523 union
524 {
525 LOGFONTA logfonta;
526 LOGFONTW logfontw;
527 EXTLOGFONTA extlogfonta;
528 EXTLOGFONTW extlogfontw;
529 ENUMLOGFONTEXA enumlogfontexa;
530 ENUMLOGFONTEXW enumlogfontexw;
531 ENUMLOGFONTEXDVA enumlogfontexdva;
532 ENUMLOGFONTEXDVW enumlogfontexdvw;
533 ENUMLOGFONTA enumlogfonta;
534 ENUMLOGFONTW enumlogfontw;
535 BYTE bData[270];
536 } u;
537 int ret;
538
539 FillMemory(&u, sizeof(u), 0x77);
540 hFont = CreateFontA(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
541 ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
542 ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont");
543 ok(hFont != 0, "\n");
544
545 SetLastError(ERROR_SUCCESS);
546 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTA), "\n");
547 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTW), "\n");
548 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 60
549 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 156
550 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTA), "\n"); // 188
551 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 192
552 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA), NULL) == sizeof(LOGFONTA), "\n"); // 260
553 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA)+1, NULL) == sizeof(LOGFONTA), "\n"); // 260
554 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 92
555 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 284
556 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 320
557 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXW), NULL) == sizeof(LOGFONTW), "\n"); // 348
558 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW), NULL) == sizeof(LOGFONTW), "\n"); // 420
559 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW)+1, NULL) == sizeof(LOGFONTW), "\n"); // 356!
560 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
561
562 ok(GetObjectA(hFont, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n");
563 ok(GetObjectA(hFont, 0, NULL) == sizeof(LOGFONTA), "\n");
564 ok(GetObjectA(hFont, 5, NULL) == sizeof(LOGFONTA), "\n");
565 ok(GetObjectA(hFont, -5, NULL) == sizeof(LOGFONTA), "\n");
566 ok(GetObjectA(hFont, 0, &u.logfonta) == 0, "\n");
567 ok(u.logfonta.lfHeight == 0x77777777, "\n");
568
569 ok(GetObjectA(hFont, 5, &u.logfonta) == 5, "\n");
570 ok(u.logfonta.lfHeight == 8, "\n");
571 ok(u.logfonta.lfWidth == 0x77777708, "\n");
572
573 ok(GetObjectA(hFont, 0, &u.logfonta) == 0, "\n");
574 ok(GetObjectA(hFont, -1, &u.logfonta) == sizeof(ENUMLOGFONTEXDVA), "\n");
575 ok(GetObjectA(hFont, 1, &u.logfonta) == 1, "\n"); // 1 -> 1
576 ok(GetObjectA(hFont, sizeof(LOGFONTA) - 1, &u.logfonta) == sizeof(LOGFONTA) - 1, "\n"); // 59 -> 59
577 ok(GetObjectA(hFont, sizeof(LOGFONTA), &u.logfonta) == sizeof(LOGFONTA), "\n"); // 60 -> 60
578 ok(GetObjectA(hFont, sizeof(LOGFONTA) + 1, &u.logfonta) == sizeof(LOGFONTA) + 1, "\n"); // 61 -> 61
579 ok(GetObjectA(hFont, sizeof(LOGFONTW) - 1, &u.logfontw) == sizeof(LOGFONTW) - 1, "\n"); // 91 -> 91
580 ok(GetObjectA(hFont, sizeof(LOGFONTW), &u.logfontw) == sizeof(LOGFONTA), "\n"); // 92 -> 60
581 ok(GetObjectA(hFont, sizeof(LOGFONTW) + 1, &u.logfontw) == sizeof(LOGFONTW) + 1, "\n"); // 93 -> 93
582 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &u.extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192 -> 192
583 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+1, &u.extlogfonta) == sizeof(EXTLOGFONTA)+1, "\n"); // 192+1 -> 192+1
584 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+16*4, &u.extlogfonta) == sizeof(EXTLOGFONTA)+16*4, "\n"); // 192+1 -> 192+1
585 ok(GetObjectA(hFont, sizeof(EXTLOGFONTW), &u.extlogfontw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 320 -> 260
586 ok(GetObjectA(hFont, 261, &u.bData) == 260, "\n"); // no
587
588 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA) - 1, "\n"); // 419
589 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 420
590 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 356!
591
592 /* LOGFONT / GetObjectW */
593 FillMemory(&u.logfontw, sizeof(LOGFONTW), 0x77);
594
595 ok(GetObjectW(hFont, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "1\n");
596 ok(GetObjectW(hFont, 0, NULL) == sizeof(LOGFONTW), "\n");
597 ok(GetObjectW(hFont, 5, NULL) == sizeof(LOGFONTW), "\n");
598 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTW), "\n");
599 ok(GetObjectW(hFont, -5, NULL) == sizeof(LOGFONTW), "\n");
600 ok(GetObjectW(hFont, 0, &u.logfontw) == 0, "\n");
601 ok(u.logfontw.lfHeight == 0x77777777, "\n");
602
603 ok(GetObjectW(hFont, 5, &u.logfontw) == 5, "\n");
604 ok(u.logfontw.lfHeight == 8, "\n");
605 ok(u.logfontw.lfWidth == 0x77777708, "\n");
606
607 ok(GetObjectA(hFont, sizeof(LOGFONTA), &u.logfonta) == sizeof(LOGFONTA), "\n"); // 60
608 ok(u.logfonta.lfHeight == 8, "\n");
609 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTA), &u.enumlogfonta) == sizeof(ENUMLOGFONTA), "\n"); // 156
610 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXA), &u.enumlogfontexa) == sizeof(ENUMLOGFONTEXA), "\n"); // 188
611 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &u.extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192
612 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &u.enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260
613 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &u.enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260
614
615 ok(GetObjectW(hFont, sizeof(LOGFONTW), &u.logfontw) == sizeof(LOGFONTW), "\n"); // 92
616 ok(GetObjectW(hFont, sizeof(LOGFONTW) + 1, &u.logfontw) == sizeof(LOGFONTW) + 1, "\n"); // 92
617 ok(GetObjectW(hFont, sizeof(LOGFONTW) - 1, &u.logfontw) == sizeof(LOGFONTW) - 1, "\n"); // 92
618 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTW), &u.enumlogfontw) == sizeof(ENUMLOGFONTW), "\n"); // 284
619 ok(GetObjectW(hFont, sizeof(EXTLOGFONTW), &u.extlogfontw) == sizeof(EXTLOGFONTW), "\n"); // 320
620 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW), &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW), "\n"); // 348
621 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW) + 1, &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW) + 1, "\n"); // 348
622 ok(GetObjectW(hFont, 355, &u.enumlogfontexdvw) == 355, "\n"); // 419
623
624 ok(GetObjectW(hFont, 356, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
625 ret = sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD);
626 ret = GetObjectW(hFont, 357, &u.enumlogfontexdvw);
627 ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n");
628 ok(GetObjectW(hFont, 357, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
629 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
630 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 420
631 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 356!
632 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
633
634 DeleteObject(hFont);
635 }
636
637 void
638 Test_Colorspace(void)
639 {
640 UCHAR buffer[1000];
641
642 SetLastError(ERROR_SUCCESS);
643 GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL);
644 //ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 60, "\n");// FIXME: what structure? fails on win7
645 ok_err(ERROR_INSUFFICIENT_BUFFER);
646 SetLastError(ERROR_SUCCESS);
647 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 0, "\n");
648 ok_err(ERROR_INSUFFICIENT_BUFFER);
649 SetLastError(ERROR_SUCCESS);
650 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 327, buffer) == 0, "\n");
651 ok_err(ERROR_INSUFFICIENT_BUFFER);
652 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, buffer) == 0, "\n");
653 ok_err(ERROR_INVALID_PARAMETER);
654
655 //ok_long(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, NULL), 0); // FIXME: fails on WHS
656 //ok_err(ERROR_INSUFFICIENT_BUFFER);
657 }
658
659 void
660 Test_MetaDC(void)
661 {
662 /* Windows does not SetLastError() on a metadc, but it doesn't seem to do anything with it */
663 HDC hMetaDC;
664 BYTE buffer[1000];
665
666 hMetaDC = CreateMetaFile(NULL);
667 ok(hMetaDC != 0, "CreateMetaFile failed, skipping tests.\n");
668 if(!hMetaDC) return;
669
670 ok(((UINT_PTR)hMetaDC & GDI_HANDLE_TYPE_MASK) == GDI_OBJECT_TYPE_METADC, "\n");
671
672 SetLastError(ERROR_SUCCESS);
673 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 0, NULL) == 0, "\n");
674 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 100, &buffer) == 0, "\n");
675 ok(GetObjectA(hMetaDC, 0, NULL) == 0, "\n");
676 ok(GetObjectA(hMetaDC, 1000, &buffer) == 0, "\n");
677 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
678 }
679
680 void
681 Test_Region(void)
682 {
683 HRGN hRgn;
684 hRgn = CreateRectRgn(0,0,5,5);
685 SetLastError(ERROR_SUCCESS);
686 ok(GetObjectW(hRgn, 0, NULL) == 0, "\n");
687 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
688 DeleteObject(hRgn);
689 }
690
691 START_TEST(GetObject)
692 {
693
694 Test_Font();
695 Test_Colorspace();
696 Test_General();
697 Test_Bitmap();
698 Test_Dibsection();
699 Test_Palette();
700 Test_Brush();
701 Test_DIBBrush();
702 Test_Pen();
703 Test_ExtPen(); // not implemented yet in ROS
704 Test_MetaDC();
705 Test_Region();
706 }
707