po: Update French translation.
[wine] / dlls / gdi32 / enhmfdrv / init.c
1 /*
2  * Enhanced MetaFile driver initialisation functions
3  *
4  * Copyright 1999 Huw D M Davies
5  *
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.
10  *
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.
15  *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <assert.h>
22 #include <stdarg.h>
23 #include <string.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winnls.h"
29 #include "gdi_private.h"
30 #include "enhmfdrv/enhmetafiledrv.h"
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
34
35 static BOOL EMFDRV_DeleteDC( PHYSDEV dev );
36
37 static const struct gdi_dc_funcs EMFDRV_Funcs =
38 {
39     NULL,                            /* pAbortDoc */
40     EMFDRV_AbortPath,                /* pAbortPath */
41     NULL,                            /* pAlphaBlend */
42     NULL,                            /* pAngleArc */
43     EMFDRV_Arc,                      /* pArc */
44     NULL,                            /* pArcTo */
45     EMFDRV_BeginPath,                /* pBeginPath */
46     NULL,                            /* pBlendImage */
47     NULL,                            /* pChoosePixelFormat */
48     EMFDRV_Chord,                    /* pChord */
49     EMFDRV_CloseFigure,              /* pCloseFigure */
50     NULL,                            /* pCopyBitmap */
51     NULL,                            /* pCreateBitmap */
52     NULL,                            /* pCreateCompatibleDC */
53     NULL,                            /* pCreateDC */
54     NULL,                            /* pDeleteBitmap */
55     EMFDRV_DeleteDC,                 /* pDeleteDC */
56     EMFDRV_DeleteObject,             /* pDeleteObject */
57     NULL,                            /* pDescribePixelFormat */
58     NULL,                            /* pDeviceCapabilities */
59     EMFDRV_Ellipse,                  /* pEllipse */
60     NULL,                            /* pEndDoc */
61     NULL,                            /* pEndPage */
62     EMFDRV_EndPath,                  /* pEndPath */
63     NULL,                            /* pEnumFonts */
64     NULL,                            /* pEnumICMProfiles */
65     EMFDRV_ExcludeClipRect,          /* pExcludeClipRect */
66     NULL,                            /* pExtDeviceMode */
67     NULL,                            /* pExtEscape */
68     EMFDRV_ExtFloodFill,             /* pExtFloodFill */
69     EMFDRV_ExtSelectClipRgn,         /* pExtSelectClipRgn */
70     EMFDRV_ExtTextOut,               /* pExtTextOut */
71     EMFDRV_FillPath,                 /* pFillPath */
72     EMFDRV_FillRgn,                  /* pFillRgn */
73     EMFDRV_FlattenPath,              /* pFlattenPath */
74     NULL,                            /* pFontIsLinked */
75     EMFDRV_FrameRgn,                 /* pFrameRgn */
76     EMFDRV_GdiComment,               /* pGdiComment */
77     NULL,                            /* pGdiRealizationInfo */
78     NULL,                            /* pGetBoundsRect */
79     NULL,                            /* pGetCharABCWidths */
80     NULL,                            /* pGetCharABCWidthsI */
81     NULL,                            /* pGetCharWidth */
82     EMFDRV_GetDeviceCaps,            /* pGetDeviceCaps */
83     NULL,                            /* pGetDeviceGammaRamp */
84     NULL,                            /* pGetFontData */
85     NULL,                            /* pGetFontUnicodeRanges */
86     NULL,                            /* pGetGlyphIndices */
87     NULL,                            /* pGetGlyphOutline */
88     NULL,                            /* pGetICMProfile */
89     NULL,                            /* pGetImage */
90     NULL,                            /* pGetKerningPairs */
91     NULL,                            /* pGetNearestColor */
92     NULL,                            /* pGetOutlineTextMetrics */
93     NULL,                            /* pGetPixel */
94     NULL,                            /* pGetPixelFormat */
95     NULL,                            /* pGetSystemPaletteEntries */
96     NULL,                            /* pGetTextCharsetInfo */
97     NULL,                            /* pGetTextExtentExPoint */
98     NULL,                            /* pGetTextExtentExPointI */
99     NULL,                            /* pGetTextFace */
100     NULL,                            /* pGetTextMetrics */
101     NULL,                            /* pGradientFill */
102     EMFDRV_IntersectClipRect,        /* pIntersectClipRect */
103     EMFDRV_InvertRgn,                /* pInvertRgn */
104     EMFDRV_LineTo,                   /* pLineTo */
105     EMFDRV_ModifyWorldTransform,     /* pModifyWorldTransform */
106     EMFDRV_MoveTo,                   /* pMoveTo */
107     EMFDRV_OffsetClipRgn,            /* pOffsetClipRgn */
108     EMFDRV_OffsetViewportOrgEx,      /* pOffsetViewportOrgEx */
109     EMFDRV_OffsetWindowOrgEx,        /* pOffsetWindowOrgEx */
110     EMFDRV_PaintRgn,                 /* pPaintRgn */
111     EMFDRV_PatBlt,                   /* pPatBlt */
112     EMFDRV_Pie,                      /* pPie */
113     EMFDRV_PolyBezier,               /* pPolyBezier */
114     EMFDRV_PolyBezierTo,             /* pPolyBezierTo */
115     NULL,                            /* pPolyDraw */
116     EMFDRV_PolyPolygon,              /* pPolyPolygon */
117     EMFDRV_PolyPolyline,             /* pPolyPolyline */
118     EMFDRV_Polygon,                  /* pPolygon */
119     EMFDRV_Polyline,                 /* pPolyline */
120     NULL,                            /* pPolylineTo */
121     NULL,                            /* pPutImage */
122     NULL,                            /* pRealizeDefaultPalette */
123     NULL,                            /* pRealizePalette */
124     EMFDRV_Rectangle,                /* pRectangle */
125     NULL,                            /* pResetDC */
126     EMFDRV_RestoreDC,                /* pRestoreDC */
127     EMFDRV_RoundRect,                /* pRoundRect */
128     EMFDRV_SaveDC,                   /* pSaveDC */
129     EMFDRV_ScaleViewportExtEx,       /* pScaleViewportExtEx */
130     EMFDRV_ScaleWindowExtEx,         /* pScaleWindowExtEx */
131     EMFDRV_SelectBitmap,             /* pSelectBitmap */
132     EMFDRV_SelectBrush,              /* pSelectBrush */
133     EMFDRV_SelectClipPath,           /* pSelectClipPath */
134     EMFDRV_SelectFont,               /* pSelectFont */
135     EMFDRV_SelectPalette,            /* pSelectPalette */
136     EMFDRV_SelectPen,                /* pSelectPen */
137     EMFDRV_SetArcDirection,          /* pSetArcDirection */
138     EMFDRV_SetBkColor,               /* pSetBkColor */
139     EMFDRV_SetBkMode,                /* pSetBkMode */
140     NULL,                            /* pSetBoundsRect */
141     EMFDRV_SetDCBrushColor,          /* pSetDCBrushColor*/
142     EMFDRV_SetDCPenColor,            /* pSetDCPenColor*/
143     EMFDRV_SetDIBitsToDevice,        /* pSetDIBitsToDevice */
144     NULL,                            /* pSetDeviceClipping */
145     NULL,                            /* pSetDeviceGammaRamp */
146     EMFDRV_SetLayout,                /* pSetLayout */
147     EMFDRV_SetMapMode,               /* pSetMapMode */
148     EMFDRV_SetMapperFlags,           /* pSetMapperFlags */
149     EMFDRV_SetPixel,                 /* pSetPixel */
150     NULL,                            /* pSetPixelFormat */
151     EMFDRV_SetPolyFillMode,          /* pSetPolyFillMode */
152     EMFDRV_SetROP2,                  /* pSetROP2 */
153     NULL,                            /* pSetRelAbs */
154     EMFDRV_SetStretchBltMode,        /* pSetStretchBltMode */
155     EMFDRV_SetTextAlign,             /* pSetTextAlign */
156     NULL,                            /* pSetTextCharacterExtra */
157     EMFDRV_SetTextColor,             /* pSetTextColor */
158     EMFDRV_SetTextJustification,     /* pSetTextJustification */ 
159     EMFDRV_SetViewportExtEx,         /* pSetViewportExtEx */
160     EMFDRV_SetViewportOrgEx,         /* pSetViewportOrgEx */
161     EMFDRV_SetWindowExtEx,           /* pSetWindowExtEx */
162     EMFDRV_SetWindowOrgEx,           /* pSetWindowOrgEx */
163     EMFDRV_SetWorldTransform,        /* pSetWorldTransform */
164     NULL,                            /* pStartDoc */
165     NULL,                            /* pStartPage */
166     EMFDRV_StretchBlt,               /* pStretchBlt */
167     EMFDRV_StretchDIBits,            /* pStretchDIBits */
168     EMFDRV_StrokeAndFillPath,        /* pStrokeAndFillPath */
169     EMFDRV_StrokePath,               /* pStrokePath */
170     NULL,                            /* pSwapBuffers */
171     NULL,                            /* pUnrealizePalette */
172     EMFDRV_WidenPath,                /* pWidenPath */
173     NULL,                            /* pwglCopyContext */
174     NULL,                            /* pwglCreateContext */
175     NULL,                            /* pwglCreateContextAttribsARB */
176     NULL,                            /* pwglDeleteContext */
177     NULL,                            /* pwglGetProcAddress */
178     NULL,                            /* pwglMakeContextCurrentARB */
179     NULL,                            /* pwglMakeCurrent */
180     NULL,                            /* pwglSetPixelFormatWINE */
181     NULL,                            /* pwglShareLists */
182     NULL,                            /* pwglUseFontBitmapsA */
183     NULL,                            /* pwglUseFontBitmapsW */
184     GDI_PRIORITY_GRAPHICS_DRV        /* priority */
185 };
186
187
188 /**********************************************************************
189  *           EMFDRV_DeleteDC
190  */
191 static BOOL EMFDRV_DeleteDC( PHYSDEV dev )
192 {
193     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
194     UINT index;
195
196     if (physDev->emh) HeapFree( GetProcessHeap(), 0, physDev->emh );
197     for(index = 0; index < physDev->handles_size; index++)
198         if(physDev->handles[index])
199             GDI_hdc_not_using_object(physDev->handles[index], dev->hdc);
200     HeapFree( GetProcessHeap(), 0, physDev->handles );
201     HeapFree( GetProcessHeap(), 0, physDev );
202     return TRUE;
203 }
204
205
206 /******************************************************************
207  *         EMFDRV_WriteRecord
208  *
209  * Warning: this function can change the pointer to the metafile header.
210  */
211 BOOL EMFDRV_WriteRecord( PHYSDEV dev, EMR *emr )
212 {
213     DWORD len;
214     ENHMETAHEADER *emh;
215     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
216
217     TRACE("record %d, size %d %s\n",
218           emr->iType, emr->nSize, physDev->hFile ? "(to disk)" : "");
219
220     assert( !(emr->nSize & 3) );
221
222     physDev->emh->nBytes += emr->nSize;
223     physDev->emh->nRecords++;
224
225     if(physDev->hFile) {
226         if (!WriteFile(physDev->hFile, emr, emr->nSize, NULL, NULL))
227             return FALSE;
228     } else {
229         DWORD nEmfSize = HeapSize(GetProcessHeap(), 0, physDev->emh);
230         len = physDev->emh->nBytes;
231         if (len > nEmfSize) {
232             nEmfSize += (nEmfSize / 2) + emr->nSize;
233             emh = HeapReAlloc(GetProcessHeap(), 0, physDev->emh, nEmfSize);
234             if (!emh) return FALSE;
235             physDev->emh = emh;
236         }
237         memcpy((CHAR *)physDev->emh + physDev->emh->nBytes - emr->nSize, emr,
238                emr->nSize);
239     }
240     return TRUE;
241 }
242
243
244 /******************************************************************
245  *         EMFDRV_UpdateBBox
246  */
247 void EMFDRV_UpdateBBox( PHYSDEV dev, RECTL *rect )
248 {
249     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
250     RECTL *bounds = &physDev->emh->rclBounds;
251     RECTL vportRect = *rect;
252
253     LPtoDP( dev->hdc, (LPPOINT)&vportRect, 2 );
254
255     /* The coordinate systems may be mirrored
256        (LPtoDP handles points, not rectangles) */
257     if (vportRect.left > vportRect.right)
258     {
259         LONG temp = vportRect.right;
260         vportRect.right = vportRect.left;
261         vportRect.left = temp;
262     }
263     if (vportRect.top > vportRect.bottom)
264     {
265         LONG temp = vportRect.bottom;
266         vportRect.bottom = vportRect.top;
267         vportRect.top = temp;
268     }
269
270     if (bounds->left > bounds->right)
271     {
272         /* first bounding rectangle */
273         *bounds = vportRect;
274     }
275     else
276     {
277         bounds->left   = min(bounds->left,   vportRect.left);
278         bounds->top    = min(bounds->top,    vportRect.top);
279         bounds->right  = max(bounds->right,  vportRect.right);
280         bounds->bottom = max(bounds->bottom, vportRect.bottom);
281     }
282 }
283
284 /**********************************************************************
285  *          CreateEnhMetaFileA   (GDI32.@)
286  */
287 HDC WINAPI CreateEnhMetaFileA(
288     HDC hdc,           /* [in] optional reference DC */
289     LPCSTR filename,   /* [in] optional filename for disk metafiles */
290     const RECT *rect,  /* [in] optional bounding rectangle */
291     LPCSTR description /* [in] optional description */
292     )
293 {
294     LPWSTR filenameW = NULL;
295     LPWSTR descriptionW = NULL;
296     HDC hReturnDC;
297     DWORD len1, len2, total;
298
299     if(filename)
300     {
301         total = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
302         filenameW = HeapAlloc( GetProcessHeap(), 0, total * sizeof(WCHAR) );
303         MultiByteToWideChar( CP_ACP, 0, filename, -1, filenameW, total );
304     }
305     if(description) {
306         len1 = strlen(description);
307         len2 = strlen(description + len1 + 1);
308         total = MultiByteToWideChar( CP_ACP, 0, description, len1 + len2 + 3, NULL, 0 );
309         descriptionW = HeapAlloc( GetProcessHeap(), 0, total * sizeof(WCHAR) );
310         MultiByteToWideChar( CP_ACP, 0, description, len1 + len2 + 3, descriptionW, total );
311     }
312
313     hReturnDC = CreateEnhMetaFileW(hdc, filenameW, rect, descriptionW);
314
315     HeapFree( GetProcessHeap(), 0, filenameW );
316     HeapFree( GetProcessHeap(), 0, descriptionW );
317
318     return hReturnDC;
319 }
320
321 /**********************************************************************
322  *          CreateEnhMetaFileW   (GDI32.@)
323  */
324 HDC WINAPI CreateEnhMetaFileW(
325     HDC           hdc,        /* [in] optional reference DC */
326     LPCWSTR       filename,   /* [in] optional filename for disk metafiles */
327     const RECT*   rect,       /* [in] optional bounding rectangle */
328     LPCWSTR       description /* [in] optional description */
329     )
330 {
331     static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
332     HDC ret;
333     DC *dc;
334     EMFDRV_PDEVICE *physDev;
335     HANDLE hFile;
336     DWORD size = 0, length = 0;
337
338     TRACE("%s\n", debugstr_w(filename) );
339
340     if (!(dc = alloc_dc_ptr( OBJ_ENHMETADC ))) return 0;
341
342     physDev = HeapAlloc(GetProcessHeap(),0,sizeof(*physDev));
343     if (!physDev) {
344         free_dc_ptr( dc );
345         return 0;
346     }
347     if(description) { /* App name\0Title\0\0 */
348         length = lstrlenW(description);
349         length += lstrlenW(description + length + 1);
350         length += 3;
351         length *= 2;
352     }
353     size = sizeof(ENHMETAHEADER) + (length + 3) / 4 * 4;
354
355     if (!(physDev->emh = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size))) {
356         HeapFree( GetProcessHeap(), 0, physDev );
357         free_dc_ptr( dc );
358         return 0;
359     }
360
361     push_dc_driver( &dc->physDev, &physDev->dev, &EMFDRV_Funcs );
362
363     physDev->handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, HANDLE_LIST_INC * sizeof(physDev->handles[0]));
364     physDev->handles_size = HANDLE_LIST_INC;
365     physDev->cur_handles = 1;
366     physDev->hFile = 0;
367     physDev->dc_brush = 0;
368     physDev->dc_pen = 0;
369     physDev->screen_dc = 0;
370     physDev->restoring = 0;
371     if (hdc)  /* if no ref, use current display */
372         physDev->ref_dc = hdc;
373     else
374         physDev->ref_dc = physDev->screen_dc = CreateDCW( displayW, NULL, NULL, NULL );
375
376     SetVirtualResolution(physDev->dev.hdc, 0, 0, 0, 0);
377
378     physDev->emh->iType = EMR_HEADER;
379     physDev->emh->nSize = size;
380
381     physDev->emh->rclBounds.left = physDev->emh->rclBounds.top = 0;
382     physDev->emh->rclBounds.right = physDev->emh->rclBounds.bottom = -1;
383
384     if(rect) {
385         physDev->emh->rclFrame.left   = rect->left;
386         physDev->emh->rclFrame.top    = rect->top;
387         physDev->emh->rclFrame.right  = rect->right;
388         physDev->emh->rclFrame.bottom = rect->bottom;
389     } else {  /* Set this to {0,0 - -1,-1} and update it at the end */
390         physDev->emh->rclFrame.left = physDev->emh->rclFrame.top = 0;
391         physDev->emh->rclFrame.right = physDev->emh->rclFrame.bottom = -1;
392     }
393
394     physDev->emh->dSignature = ENHMETA_SIGNATURE;
395     physDev->emh->nVersion = 0x10000;
396     physDev->emh->nBytes = physDev->emh->nSize;
397     physDev->emh->nRecords = 1;
398     physDev->emh->nHandles = 1;
399
400     physDev->emh->sReserved = 0; /* According to docs, this is reserved and must be 0 */
401     physDev->emh->nDescription = length / 2;
402
403     physDev->emh->offDescription = length ? sizeof(ENHMETAHEADER) : 0;
404
405     physDev->emh->nPalEntries = 0; /* I guess this should start at 0 */
406
407     /* Size in pixels */
408     physDev->emh->szlDevice.cx = GetDeviceCaps( physDev->ref_dc, HORZRES );
409     physDev->emh->szlDevice.cy = GetDeviceCaps( physDev->ref_dc, VERTRES );
410
411     /* Size in millimeters */
412     physDev->emh->szlMillimeters.cx = GetDeviceCaps( physDev->ref_dc, HORZSIZE );
413     physDev->emh->szlMillimeters.cy = GetDeviceCaps( physDev->ref_dc, VERTSIZE );
414
415     /* Size in micrometers */
416     physDev->emh->szlMicrometers.cx = physDev->emh->szlMillimeters.cx * 1000;
417     physDev->emh->szlMicrometers.cy = physDev->emh->szlMillimeters.cy * 1000;
418
419     memcpy((char *)physDev->emh + sizeof(ENHMETAHEADER), description, length);
420
421     if (filename)  /* disk based metafile */
422     {
423         if ((hFile = CreateFileW(filename, GENERIC_WRITE | GENERIC_READ, 0,
424                                  NULL, CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
425             free_dc_ptr( dc );
426             return 0;
427         }
428         if (!WriteFile( hFile, physDev->emh, size, NULL, NULL )) {
429             free_dc_ptr( dc );
430             return 0;
431         }
432         physDev->hFile = hFile;
433     }
434
435     TRACE("returning %p\n", physDev->dev.hdc);
436     ret = physDev->dev.hdc;
437     release_dc_ptr( dc );
438
439     return ret;
440 }
441
442 /******************************************************************
443  *             CloseEnhMetaFile (GDI32.@)
444  */
445 HENHMETAFILE WINAPI CloseEnhMetaFile(HDC hdc) /* [in] metafile DC */
446 {
447     HENHMETAFILE hmf;
448     EMFDRV_PDEVICE *physDev;
449     DC *dc;
450     EMREOF emr;
451     HANDLE hMapping = 0;
452
453     TRACE("(%p)\n", hdc );
454
455     if (!(dc = get_dc_ptr( hdc ))) return NULL;
456     if (dc->header.type != OBJ_ENHMETADC)
457     {
458         release_dc_ptr( dc );
459         return NULL;
460     }
461     if (dc->refcount != 1)
462     {
463         FIXME( "not deleting busy DC %p refcount %u\n", hdc, dc->refcount );
464         release_dc_ptr( dc );
465         return NULL;
466     }
467     physDev = (EMFDRV_PDEVICE *)dc->physDev;
468
469     if(dc->saveLevel)
470         RestoreDC(hdc, 1);
471
472     if (physDev->dc_brush) DeleteObject( physDev->dc_brush );
473     if (physDev->dc_pen) DeleteObject( physDev->dc_pen );
474     if (physDev->screen_dc) DeleteDC( physDev->screen_dc );
475
476     emr.emr.iType = EMR_EOF;
477     emr.emr.nSize = sizeof(emr);
478     emr.nPalEntries = 0;
479     emr.offPalEntries = FIELD_OFFSET(EMREOF, nSizeLast);
480     emr.nSizeLast = emr.emr.nSize;
481     EMFDRV_WriteRecord( dc->physDev, &emr.emr );
482
483     /* Update rclFrame if not initialized in CreateEnhMetaFile */
484     if(physDev->emh->rclFrame.left > physDev->emh->rclFrame.right) {
485         physDev->emh->rclFrame.left = physDev->emh->rclBounds.left *
486           physDev->emh->szlMillimeters.cx * 100 / physDev->emh->szlDevice.cx;
487         physDev->emh->rclFrame.top = physDev->emh->rclBounds.top *
488           physDev->emh->szlMillimeters.cy * 100 / physDev->emh->szlDevice.cy;
489         physDev->emh->rclFrame.right = physDev->emh->rclBounds.right *
490           physDev->emh->szlMillimeters.cx * 100 / physDev->emh->szlDevice.cx;
491         physDev->emh->rclFrame.bottom = physDev->emh->rclBounds.bottom *
492           physDev->emh->szlMillimeters.cy * 100 / physDev->emh->szlDevice.cy;
493     }
494
495     if (physDev->hFile)  /* disk based metafile */
496     {
497         if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0)
498         {
499             CloseHandle( physDev->hFile );
500             free_dc_ptr( dc );
501             return 0;
502         }
503
504         if (!WriteFile(physDev->hFile, physDev->emh, sizeof(*physDev->emh),
505                        NULL, NULL))
506         {
507             CloseHandle( physDev->hFile );
508             free_dc_ptr( dc );
509             return 0;
510         }
511         HeapFree( GetProcessHeap(), 0, physDev->emh );
512         hMapping = CreateFileMappingA(physDev->hFile, NULL, PAGE_READONLY, 0,
513                                       0, NULL);
514         TRACE("hMapping = %p\n", hMapping );
515         physDev->emh = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
516         TRACE("view = %p\n", physDev->emh );
517         CloseHandle( hMapping );
518         CloseHandle( physDev->hFile );
519     }
520
521     hmf = EMF_Create_HENHMETAFILE( physDev->emh, (physDev->hFile != 0) );
522     physDev->emh = NULL;  /* So it won't be deleted */
523     free_dc_ptr( dc );
524     return hmf;
525 }