2 * Unit tests for metafile functions
4 * Copyright (c) 2002 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "wine/test.h"
31 static LOGFONTA orig_lf
;
32 static BOOL emr_processed
= FALSE
;
34 /* Arbitrarily chosen values for the second co-ordinate of a metafile line */
38 static int CALLBACK
emf_enum_proc(HDC hdc
, HANDLETABLE
*handle_table
,
39 const ENHMETARECORD
*emr
, int n_objs
, LPARAM param
)
44 INT
*orig_dx
= (INT
*)param
;
48 trace("hdc %p, emr->iType %ld, emr->nSize %ld, param %p\n",
49 hdc
, emr
->iType
, emr
->nSize
, (void *)param
);
53 PlayEnhMetaFileRecord(hdc
, handle_table
, emr
, n_objs
);
63 const EMREXTTEXTOUTA
*emr_ExtTextOutA
= (const EMREXTTEXTOUTA
*)emr
;
64 dx
= (const INT
*)((const char *)emr
+ emr_ExtTextOutA
->emrtext
.offDx
);
66 ret
= GetObjectA(GetCurrentObject(hdc
, OBJ_FONT
), sizeof(device_lf
), &device_lf
);
67 ok( ret
== sizeof(device_lf
), "GetObjectA error %ld\n", GetLastError());
69 /* compare up to lfOutPrecision, other values are not interesting,
70 * and in fact sometimes arbitrary adapted by Win9x.
72 ok(!memcmp(&orig_lf
, &device_lf
, FIELD_OFFSET(LOGFONTA
, lfOutPrecision
)), "fonts don't match\n");
73 ok(!lstrcmpA(orig_lf
.lfFaceName
, device_lf
.lfFaceName
), "font names don't match\n");
75 for(i
= 0; i
< emr_ExtTextOutA
->emrtext
.nChars
; i
++)
77 ok(orig_dx
[i
] == dx
[i
], "pass %d: dx[%ld] (%d) didn't match %d\n",
78 n_record
, i
, dx
[i
], orig_dx
[i
]);
87 const EMREXTTEXTOUTW
*emr_ExtTextOutW
= (const EMREXTTEXTOUTW
*)emr
;
88 dx
= (const INT
*)((const char *)emr
+ emr_ExtTextOutW
->emrtext
.offDx
);
90 ret
= GetObjectA(GetCurrentObject(hdc
, OBJ_FONT
), sizeof(device_lf
), &device_lf
);
91 ok( ret
== sizeof(device_lf
), "GetObjectA error %ld\n", GetLastError());
93 /* compare up to lfOutPrecision, other values are not interesting,
94 * and in fact sometimes arbitrary adapted by Win9x.
96 ok(!memcmp(&orig_lf
, &device_lf
, FIELD_OFFSET(LOGFONTA
, lfOutPrecision
)), "fonts don't match\n");
97 ok(!lstrcmpA(orig_lf
.lfFaceName
, device_lf
.lfFaceName
), "font names don't match\n");
99 for(i
= 0; i
< emr_ExtTextOutW
->emrtext
.nChars
; i
++)
101 ok(orig_dx
[i
] == dx
[i
], "pass %d: dx[%ld] (%d) didn't match %d\n",
102 n_record
, i
, dx
[i
], orig_dx
[i
]);
105 emr_processed
= TRUE
;
116 static void test_ExtTextOut(void)
119 HDC hdcDisplay
, hdcMetafile
;
120 HENHMETAFILE hMetafile
;
122 static const char text
[] = "Simple text to test ExtTextOut on metafiles";
124 static const RECT rc
= { 0, 0, 100, 100 };
127 assert(sizeof(dx
)/sizeof(dx
[0]) >= lstrlenA(text
));
129 /* Win9x doesn't play EMFs on invisible windows */
130 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
| WS_VISIBLE
,
131 0, 0, 200, 200, 0, 0, 0, NULL
);
132 ok(hwnd
!= 0, "CreateWindowExA error %ld\n", GetLastError());
134 hdcDisplay
= GetDC(hwnd
);
135 ok(hdcDisplay
!= 0, "GetDC error %ld\n", GetLastError());
137 trace("hdcDisplay %p\n", hdcDisplay
);
139 SetMapMode(hdcDisplay
, MM_TEXT
);
141 memset(&orig_lf
, 0, sizeof(orig_lf
));
143 orig_lf
.lfCharSet
= ANSI_CHARSET
;
144 orig_lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
145 orig_lf
.lfWeight
= FW_DONTCARE
;
146 orig_lf
.lfHeight
= 7;
147 orig_lf
.lfQuality
= DEFAULT_QUALITY
;
148 lstrcpyA(orig_lf
.lfFaceName
, "Arial");
149 hFont
= CreateFontIndirectA(&orig_lf
);
150 ok(hFont
!= 0, "CreateFontIndirectA error %ld\n", GetLastError());
152 hFont
= SelectObject(hdcDisplay
, hFont
);
154 len
= lstrlenA(text
);
155 for (i
= 0; i
< len
; i
++)
157 ret
= GetCharWidthA(hdcDisplay
, text
[i
], text
[i
], &dx
[i
]);
158 ok( ret
, "GetCharWidthA error %ld\n", GetLastError());
160 hFont
= SelectObject(hdcDisplay
, hFont
);
162 hdcMetafile
= CreateEnhMetaFileA(hdcDisplay
, NULL
, NULL
, NULL
);
163 ok(hdcMetafile
!= 0, "CreateEnhMetaFileA error %ld\n", GetLastError());
165 trace("hdcMetafile %p\n", hdcMetafile
);
167 ok(GetDeviceCaps(hdcMetafile
, TECHNOLOGY
) == DT_RASDISPLAY
,
168 "GetDeviceCaps(TECHNOLOGY) has to return DT_RASDISPLAY for a display based EMF\n");
170 hFont
= SelectObject(hdcMetafile
, hFont
);
172 /* 1. pass NULL lpDx */
173 ret
= ExtTextOutA(hdcMetafile
, 0, 0, 0, &rc
, text
, lstrlenA(text
), NULL
);
174 ok( ret
, "ExtTextOutA error %ld\n", GetLastError());
176 /* 2. pass custom lpDx */
177 ret
= ExtTextOutA(hdcMetafile
, 0, 20, 0, &rc
, text
, lstrlenA(text
), dx
);
178 ok( ret
, "ExtTextOutA error %ld\n", GetLastError());
180 hFont
= SelectObject(hdcMetafile
, hFont
);
181 ret
= DeleteObject(hFont
);
182 ok( ret
, "DeleteObject error %ld\n", GetLastError());
184 hMetafile
= CloseEnhMetaFile(hdcMetafile
);
185 ok(hMetafile
!= 0, "CloseEnhMetaFile error %ld\n", GetLastError());
187 ok(!GetObjectType(hdcMetafile
), "CloseEnhMetaFile has to destroy metafile hdc\n");
189 ret
= PlayEnhMetaFile(hdcDisplay
, hMetafile
, &rc
);
190 ok( ret
, "PlayEnhMetaFile error %ld\n", GetLastError());
192 ret
= EnumEnhMetaFile(hdcDisplay
, hMetafile
, emf_enum_proc
, dx
, &rc
);
193 ok( ret
, "EnumEnhMetaFile error %ld\n", GetLastError());
195 ok(emr_processed
, "EnumEnhMetaFile couldn't find EMR_EXTTEXTOUTA or EMR_EXTTEXTOUTW record\n");
197 ok(!EnumEnhMetaFile(hdcDisplay
, hMetafile
, emf_enum_proc
, dx
, NULL
),
198 "A valid hdc has to require a valid rc\n");
200 ok(EnumEnhMetaFile(NULL
, hMetafile
, emf_enum_proc
, dx
, NULL
),
201 "A null hdc does not require a valid rc\n");
203 ret
= DeleteEnhMetaFile(hMetafile
);
204 ok( ret
, "DeleteEnhMetaFile error %ld\n", GetLastError());
205 ret
= ReleaseDC(hwnd
, hdcDisplay
);
206 ok( ret
, "ReleaseDC error %ld\n", GetLastError());
209 /* Win-format metafile (mfdrv) tests */
210 /* These tests compare the generated metafiles byte-by-byte */
211 /* with the nominal results. */
213 /* Maximum size of sample metafiles in bytes. */
214 #define MF_BUFSIZE 256
216 /* 8x8 bitmap data for a pattern brush */
217 static const unsigned char SAMPLE_PATTERN_BRUSH
[] = {
218 0x01, 0x00, 0x02, 0x00,
219 0x03, 0x00, 0x04, 0x00,
220 0x05, 0x00, 0x06, 0x00,
221 0x07, 0x00, 0x08, 0x00
224 /* Sample metafiles to be compared to the outputs of the
228 static const unsigned char MF_BLANK_BITS
[] = {
229 0x01, 0x00, 0x09, 0x00, 0x00, 0x03, 0x0c, 0x00,
230 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
231 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
234 static const unsigned char MF_GRAPHICS_BITS
[] = {
235 0x01, 0x00, 0x09, 0x00, 0x00, 0x03, 0x22, 0x00,
236 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
237 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x14, 0x02,
238 0x01, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00,
239 0x13, 0x02, 0x02, 0x00, 0x02, 0x00, 0x05, 0x00,
240 0x00, 0x00, 0x14, 0x02, 0x01, 0x00, 0x01, 0x00,
241 0x07, 0x00, 0x00, 0x00, 0x18, 0x04, 0x02, 0x00,
242 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
243 0x00, 0x00, 0x00, 0x00
246 static const unsigned char MF_PATTERN_BRUSH_BITS
[] = {
247 0x01, 0x00, 0x09, 0x00, 0x00, 0x03, 0x3d, 0x00,
248 0x00, 0x00, 0x01, 0x00, 0x2d, 0x00, 0x00, 0x00,
249 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x42, 0x01,
250 0x03, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
251 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
252 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
253 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
254 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
255 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
256 0xff, 0xff, 0xff, 0x00, 0x08, 0x00, 0x00, 0x00,
257 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
258 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
259 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
260 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
261 0x2d, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
265 /* For debugging or dumping the raw metafiles produced by
266 * new test functions.
269 static void dump_mf_bits (const HMETAFILE mf
, const char *desc
)
271 char buf
[MF_BUFSIZE
];
274 mfsize
= GetMetaFileBitsEx (mf
, MF_BUFSIZE
, buf
);
275 ok (mfsize
> 0, "%s: GetMetaFileBitsEx failed.\n", desc
);
277 printf ("MetaFile %s has bits:\n{\n ", desc
);
278 for (i
=0; i
<mfsize
; i
++)
280 printf ("0x%.2hhx", buf
[i
]);
291 /* Compare the metafile produced by a test function with the
292 * expected raw metafile data in "bits".
293 * Return value is 0 for a perfect match,
294 * -1 if lengths aren't equal,
295 * otherwise returns the number of non-matching bytes.
298 static int compare_mf_bits (const HMETAFILE mf
, const char *bits
, UINT bsize
,
301 char buf
[MF_BUFSIZE
];
305 mfsize
= GetMetaFileBitsEx (mf
, MF_BUFSIZE
, buf
);
306 ok (mfsize
> 0, "%s: GetMetaFileBitsEx failed.\n", desc
);
307 if (mfsize
< MF_BUFSIZE
)
308 ok (mfsize
== bsize
, "%s: mfsize=%d, bsize=%d.\n",
309 desc
, mfsize
, bsize
);
311 ok (bsize
>= MF_BUFSIZE
, "%s: mfsize > bufsize (%d bytes), bsize=%d.\n",
312 desc
, mfsize
, bsize
);
317 for (i
=0; i
<bsize
; i
++)
319 if (buf
[i
] != bits
[i
])
322 ok (diff
== 0, "%s: mfsize=%d, bsize=%d, diff=%d\n",
323 desc
, mfsize
, bsize
, diff
);
328 /* Test a blank metafile. May be used as a template for new tests. */
330 static void test_mf_Blank(void)
337 hdcMetafile
= CreateMetaFileA(NULL
);
338 ok(hdcMetafile
!= 0, "CreateMetaFileA(NULL) error %ld\n", GetLastError());
339 trace("hdcMetafile %p\n", hdcMetafile
);
341 /* Tests on metafile initialization */
342 caps
= GetDeviceCaps (hdcMetafile
, TECHNOLOGY
);
343 ok (caps
== DT_METAFILE
,
344 "GetDeviceCaps: TECHNOLOGY=%d != DT_METAFILE.\n", caps
);
346 hMetafile
= CloseMetaFile(hdcMetafile
);
347 ok(hMetafile
!= 0, "CloseMetaFile error %ld\n", GetLastError());
348 ok(!GetObjectType(hdcMetafile
), "CloseMetaFile has to destroy metafile hdc\n");
350 if (compare_mf_bits (hMetafile
, MF_BLANK_BITS
, sizeof(MF_BLANK_BITS
),
352 dump_mf_bits (hMetafile
, "mf_Blank");
354 ret
= DeleteMetaFile(hMetafile
);
355 ok( ret
, "DeleteMetaFile(%p) error %ld\n", hMetafile
, GetLastError());
358 /* Simple APIs from mfdrv/graphics.c
361 static void test_mf_Graphics()
368 hdcMetafile
= CreateMetaFileA(NULL
);
369 ok(hdcMetafile
!= 0, "CreateMetaFileA(NULL) error %ld\n", GetLastError());
370 trace("hdcMetafile %p\n", hdcMetafile
);
372 ret
= MoveToEx(hdcMetafile
, 1, 1, NULL
);
373 ok( ret
, "MoveToEx error %ld.\n", GetLastError());
374 ret
= LineTo(hdcMetafile
, 2, 2);
375 ok( ret
, "LineTo error %ld.\n", GetLastError());
376 ret
= MoveToEx(hdcMetafile
, 1, 1, &oldpoint
);
377 ok( ret
, "MoveToEx error %ld.\n", GetLastError());
379 /* oldpoint gets garbage under Win XP, so the following test would
380 * work under Wine but fails under Windows:
382 * ok((oldpoint.x == 2) && (oldpoint.y == 2),
383 * "MoveToEx: (x, y) = (%ld, %ld), should be (2, 2).\n",
384 * oldpoint.x, oldpoint.y);
387 ret
= Ellipse(hdcMetafile
, 0, 0, 2, 2);
388 ok( ret
, "Ellipse error %ld.\n", GetLastError());
390 hMetafile
= CloseMetaFile(hdcMetafile
);
391 ok(hMetafile
!= 0, "CloseMetaFile error %ld\n", GetLastError());
392 ok(!GetObjectType(hdcMetafile
), "CloseMetaFile has to destroy metafile hdc\n");
394 if (compare_mf_bits (hMetafile
, MF_GRAPHICS_BITS
, sizeof(MF_GRAPHICS_BITS
),
396 dump_mf_bits (hMetafile
, "mf_Graphics");
398 ret
= DeleteMetaFile(hMetafile
);
399 ok( ret
, "DeleteMetaFile(%p) error %ld\n",
400 hMetafile
, GetLastError());
403 static void test_mf_PatternBrush(void)
411 orig_lb
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LOGBRUSH
));
413 orig_lb
->lbStyle
= BS_PATTERN
;
414 orig_lb
->lbColor
= RGB(0, 0, 0);
415 orig_lb
->lbHatch
= (INT
) CreateBitmap (8, 8, 1, 1, SAMPLE_PATTERN_BRUSH
);
416 ok((HBITMAP
*)orig_lb
->lbHatch
!= NULL
, "CreateBitmap error %ld.\n", GetLastError());
418 hBrush
= CreateBrushIndirect (orig_lb
);
419 ok(hBrush
!= 0, "CreateBrushIndirect error %ld\n", GetLastError());
421 hdcMetafile
= CreateMetaFileA(NULL
);
422 ok(hdcMetafile
!= 0, "CreateMetaFileA error %ld\n", GetLastError());
423 trace("hdcMetafile %p\n", hdcMetafile
);
425 hBrush
= SelectObject(hdcMetafile
, hBrush
);
426 ok(hBrush
!= 0, "SelectObject error %ld.\n", GetLastError());
428 hMetafile
= CloseMetaFile(hdcMetafile
);
429 ok(hMetafile
!= 0, "CloseMetaFile error %ld\n", GetLastError());
430 ok(!GetObjectType(hdcMetafile
), "CloseMetaFile has to destroy metafile hdc\n");
432 if (compare_mf_bits (hMetafile
, MF_PATTERN_BRUSH_BITS
, sizeof(MF_PATTERN_BRUSH_BITS
),
433 "mf_Pattern_Brush") != 0)
434 dump_mf_bits (hMetafile
, "mf_Pattern_Brush");
436 ret
= DeleteMetaFile(hMetafile
);
437 ok( ret
, "DeleteMetaFile error %ld\n", GetLastError());
438 ret
= DeleteObject(hBrush
);
439 ok( ret
, "DeleteObject(HBRUSH) error %ld\n", GetLastError());
440 ret
= DeleteObject((HBITMAP
*)orig_lb
->lbHatch
);
441 ok( ret
, "DeleteObject(HBITMAP) error %ld\n",
443 HeapFree (GetProcessHeap(), 0, orig_lb
);
446 static INT CALLBACK
EmfMmTextEnumProc(HDC hdc
, HANDLETABLE
*lpHTable
, const ENHMETARECORD
*lpEMFR
, INT nObj
, LPARAM lpData
)
448 POINT mapping
[2] = { { 0, 0 }, { 1000, 1000 } };
449 LPtoDP(hdc
, mapping
, 2);
450 trace("Meta record: iType = %ld, (%ld,%ld)-(%ld,%ld)\n", lpEMFR
->iType
, mapping
[0].x
, mapping
[0].y
, mapping
[1].x
, mapping
[1].y
);
451 if (lpEMFR
->iType
== EMR_LINETO
)
453 FLOAT xSrcPixSize
, ySrcPixSize
, xscale
, yscale
;
454 INT xframe
= LINE_X
* (float)GetDeviceCaps(hdc
, HORZSIZE
) * 100.0f
/ (float)GetDeviceCaps(hdc
, HORZRES
);
455 INT yframe
= LINE_Y
* (float)GetDeviceCaps(hdc
, VERTSIZE
) * 100.0f
/ (float)GetDeviceCaps(hdc
, VERTRES
);
460 xSrcPixSize
= (FLOAT
) GetDeviceCaps(hdc
, HORZSIZE
) / GetDeviceCaps(hdc
, HORZRES
);
461 ySrcPixSize
= (FLOAT
) GetDeviceCaps(hdc
, VERTSIZE
) / GetDeviceCaps(hdc
, VERTRES
);
462 xscale
= (FLOAT
) 1000 * 100.0 /
463 xframe
* xSrcPixSize
;
464 yscale
= (FLOAT
) 1000 * 100.0 /
465 yframe
* ySrcPixSize
;
466 x1
= (INT
)floor(xscale
* 100.0 + 0.5f
);
467 y1
= (INT
)floor(yscale
* 100.0 + 0.5f
);
468 ok(mapping
[0].x
== x0
&& mapping
[0].y
== y0
&& mapping
[1].x
== x1
&& mapping
[1].y
== y1
,
469 "(%ld,%ld)->(%ld,%ld), expected (%d,%d)->(%d,%d)\n",
470 mapping
[0].x
, mapping
[0].y
, mapping
[1].x
, mapping
[1].y
,
473 PlayEnhMetaFileRecord(hdc
, lpHTable
, lpEMFR
, nObj
);
477 static INT CALLBACK
EmfMmAnisotropicEnumProc(HDC hdc
, HANDLETABLE
*lpHTable
, const ENHMETARECORD
*lpEMFR
, INT nObj
, LPARAM lpData
)
479 POINT mapping
[2] = { { 0, 0 }, { 1000, 1000 } };
480 LPtoDP(hdc
, mapping
, 2);
481 trace("Meta record: iType = %ld, (%ld,%ld)-(%ld,%ld)\n", lpEMFR
->iType
, mapping
[0].x
, mapping
[0].y
, mapping
[1].x
, mapping
[1].y
);
482 if (lpEMFR
->iType
== EMR_LINETO
)
484 INT x0
= MulDiv(0, GetDeviceCaps(hdc
, HORZSIZE
) * 100, GetDeviceCaps(hdc
, HORZRES
));
485 INT y0
= MulDiv(0, GetDeviceCaps(hdc
, VERTSIZE
) * 100, GetDeviceCaps(hdc
, VERTRES
));
486 INT x1
= MulDiv(1000, GetDeviceCaps(hdc
, HORZSIZE
) * 100, GetDeviceCaps(hdc
, HORZRES
));
487 INT y1
= MulDiv(1000, GetDeviceCaps(hdc
, VERTSIZE
) * 100, GetDeviceCaps(hdc
, VERTRES
));
488 ok(mapping
[0].x
== x0
&& mapping
[0].y
== y0
&& mapping
[1].x
== x1
&& mapping
[1].y
== y1
,
489 "(%ld,%ld)->(%ld,%ld), expected (%d,%d)->(%d,%d)\n",
490 mapping
[0].x
, mapping
[0].y
, mapping
[1].x
, mapping
[1].y
,
493 PlayEnhMetaFileRecord(hdc
, lpHTable
, lpEMFR
, nObj
);
497 static HENHMETAFILE
create_converted_emf(const METAFILEPICT
*mfp
)
505 hdcMf
= CreateMetaFile(NULL
);
506 ok(hdcMf
!= NULL
, "CreateMetaFile failed with error %ld\n", GetLastError());
507 ret
= LineTo(hdcMf
, (INT
)LINE_X
, (INT
)LINE_Y
);
508 ok(ret
, "LineTo failed with error %ld\n", GetLastError());
509 hmf
= CloseMetaFile(hdcMf
);
510 ok(hmf
!= NULL
, "CloseMetaFile failed with error %ld\n", GetLastError());
511 size
= GetMetaFileBitsEx(hmf
, 0, NULL
);
512 ok(size
, "GetMetaFileBitsEx failed with error %ld\n", GetLastError());
513 pBits
= HeapAlloc(GetProcessHeap(), 0, size
);
514 GetMetaFileBitsEx(hmf
, size
, pBits
);
516 return SetWinMetaFileBits(size
, pBits
, NULL
, mfp
);
519 static void test_mf_conversions()
521 trace("Testing MF->EMF conversion (MM_ANISOTROPIC)\n");
523 HDC hdcOffscreen
= CreateCompatibleDC(NULL
);
526 RECT rect
= { 0, 0, 100, 100 };
527 mfp
.mm
= MM_ANISOTROPIC
;
531 hemf
= create_converted_emf(&mfp
);
532 EnumEnhMetaFile(hdcOffscreen
, hemf
, EmfMmAnisotropicEnumProc
, NULL
, &rect
);
533 DeleteEnhMetaFile(hemf
);
534 DeleteDC(hdcOffscreen
);
537 trace("Testing MF->EMF conversion (MM_TEXT)\n");
539 HDC hdcOffscreen
= CreateCompatibleDC(NULL
);
542 RECT rect
= { 0, 0, 100, 100 };
547 hemf
= create_converted_emf(&mfp
);
548 EnumEnhMetaFile(hdcOffscreen
, hemf
, EmfMmTextEnumProc
, NULL
, &rect
);
549 DeleteEnhMetaFile(hemf
);
550 DeleteDC(hdcOffscreen
);
553 trace("Testing MF->EMF conversion (NULL mfp)\n");
555 HDC hdcOffscreen
= CreateCompatibleDC(NULL
);
557 RECT rect
= { 0, 0, 100, 100 };
558 hemf
= create_converted_emf(NULL
);
559 EnumEnhMetaFile(hdcOffscreen
, hemf
, EmfMmTextEnumProc
, NULL
, &rect
);
560 DeleteEnhMetaFile(hemf
);
561 DeleteDC(hdcOffscreen
);
565 static BOOL (WINAPI
*pGdiIsMetaPrintDC
)(HDC
);
566 static BOOL (WINAPI
*pGdiIsMetaFileDC
)(HDC
);
567 static BOOL (WINAPI
*pGdiIsPlayMetafileDC
)(HDC
);
569 static void test_gdiis(void)
571 RECT rect
= {0,0,100,100};
572 HDC hdc
, hemfDC
, hmfDC
;
576 /* resolve all the functions */
577 hgdi32
= GetModuleHandle("gdi32");
578 pGdiIsMetaPrintDC
= (void*) GetProcAddress(hgdi32
, "GdiIsMetaPrintDC");
579 pGdiIsMetaFileDC
= (void*) GetProcAddress(hgdi32
, "GdiIsMetaFileDC");
580 pGdiIsPlayMetafileDC
= (void*) GetProcAddress(hgdi32
, "GdiIsPlayMetafileDC");
582 /* they should all exist or none should exist */
583 if(!pGdiIsMetaPrintDC
)
586 /* try with nothing */
587 ok(!pGdiIsMetaPrintDC(NULL
), "ismetaprint with NULL parameter\n");
588 ok(!pGdiIsMetaFileDC(NULL
), "ismetafile with NULL parameter\n");
589 ok(!pGdiIsPlayMetafileDC(NULL
), "isplaymetafile with NULL parameter\n");
591 /* try with a metafile */
592 hmfDC
= CreateMetaFile(NULL
);
593 ok(!pGdiIsMetaPrintDC(hmfDC
), "ismetaprint on metafile\n");
594 ok(pGdiIsMetaFileDC(hmfDC
), "ismetafile on metafile\n");
595 ok(!pGdiIsPlayMetafileDC(hmfDC
), "isplaymetafile on metafile\n");
596 DeleteObject(CloseMetaFile(hmfDC
));
598 /* try with an enhanced metafile */
600 hemfDC
= CreateEnhMetaFileW(hdc
, NULL
, &rect
, NULL
);
601 ok(hemfDC
!= NULL
, "failed to create emf\n");
603 ok(!pGdiIsMetaPrintDC(hemfDC
), "ismetaprint on emf\n");
604 ok(pGdiIsMetaFileDC(hemfDC
), "ismetafile on emf\n");
605 ok(!pGdiIsPlayMetafileDC(hemfDC
), "isplaymetafile on emf\n");
607 hemf
= CloseEnhMetaFile(hemfDC
);
608 ok(hemf
!= NULL
, "failed to close EMF\n");
615 /* For enhanced metafiles (enhmfdrv) */
618 /* For win-format metafiles (mfdrv) */
621 test_mf_PatternBrush();
623 /* For metafile conversions */
624 test_mf_conversions();