Commit 40d5f4cd authored by Peter Hunnisett's avatar Peter Hunnisett Committed by Alexandre Julliard

Store reference hdc size into enhanced metafile header when creating.

parent bc3ab4c5
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "enhmetafiledrv.h" #include "enhmetafiledrv.h"
#include "wine/winestring.h" #include "wine/winestring.h"
#include "debugtools.h" #include "debugtools.h"
#include "winuser.h"
#include <string.h> #include <string.h>
...@@ -241,6 +242,7 @@ HDC WINAPI CreateEnhMetaFileW( ...@@ -241,6 +242,7 @@ HDC WINAPI CreateEnhMetaFileW(
) )
{ {
DC *dc; DC *dc;
HDC hRefDC = hdc ? hdc : GetDC(0); /* If no ref, use current display */
EMFDRV_PDEVICE *physDev; EMFDRV_PDEVICE *physDev;
HFILE hFile; HFILE hFile;
DWORD size = 0, length = 0; DWORD size = 0, length = 0;
...@@ -276,15 +278,31 @@ HDC WINAPI CreateEnhMetaFileW( ...@@ -276,15 +278,31 @@ HDC WINAPI CreateEnhMetaFileW(
physDev->emh->iType = EMR_HEADER; physDev->emh->iType = EMR_HEADER;
physDev->emh->nSize = size; physDev->emh->nSize = size;
physDev->emh->rclBounds.left = physDev->emh->rclBounds.top = 0;
physDev->emh->rclBounds.right = physDev->emh->rclBounds.bottom = -1;
physDev->emh->dSignature = ENHMETA_SIGNATURE; physDev->emh->dSignature = ENHMETA_SIGNATURE;
physDev->emh->nVersion = 0x10000; physDev->emh->nVersion = 0x10000;
physDev->emh->nBytes = physDev->emh->nSize; physDev->emh->nBytes = physDev->emh->nSize;
physDev->emh->nRecords = 1; physDev->emh->nRecords = 1;
physDev->emh->nHandles = 1; physDev->emh->nHandles = 1;
physDev->emh->rclBounds.left = physDev->emh->rclBounds.top = 0;
physDev->emh->rclBounds.right = physDev->emh->rclBounds.bottom = -1; physDev->emh->sReserved = 0; /* According to docs, this is reserved and must be 0 */
physDev->emh->nDescription = length / 2; physDev->emh->nDescription = length / 2;
physDev->emh->offDescription = length ? sizeof(ENHMETAHEADER) : 0; physDev->emh->offDescription = length ? sizeof(ENHMETAHEADER) : 0;
physDev->emh->nPalEntries = 0; /* I guess this should start at 0 */
/* Size in pixels */
physDev->emh->szlDevice.cx = GetDeviceCaps( hRefDC, HORZRES );
physDev->emh->szlDevice.cy = GetDeviceCaps( hRefDC, VERTRES );
/* Size in millimeters */
physDev->emh->szlMillimeters.cx = GetDeviceCaps( hRefDC, HORZSIZE );
physDev->emh->szlMillimeters.cy = GetDeviceCaps( hRefDC, VERTSIZE );
memcpy((char *)physDev->emh + sizeof(ENHMETAHEADER), description, length); memcpy((char *)physDev->emh + sizeof(ENHMETAHEADER), description, length);
if (filename) /* disk based metafile */ if (filename) /* disk based metafile */
...@@ -301,6 +319,9 @@ HDC WINAPI CreateEnhMetaFileW( ...@@ -301,6 +319,9 @@ HDC WINAPI CreateEnhMetaFileW(
physDev->hFile = hFile; physDev->hFile = hFile;
} }
if( !hdc )
ReleaseDC( 0, hRefDC );
TRACE("returning %04x\n", dc->hSelf); TRACE("returning %04x\n", dc->hSelf);
return dc->hSelf; return dc->hSelf;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment