MetafileHeader type
The header of a Metafile: its kind, size, resolution and bounds.
Metafile.MetafileHeader returns one, and so do the functions GetMetafileHeader, GetMetafileHeaderFromEmf and GetMetafileHeaderFromWmf, which read the header of a file, a stream or a handle. The type mirrors the GDI+ MetafileHeader class. Besides its fields it has properties that answer the usual questions about the kind of metafile.
Fields
| Field | Type | Meaning |
|---|---|---|
| Type | GpMetafileType | The kind of metafile: WMF, placeable WMF, EMF, EMF+ only or EMF+ dual. |
| Size | UINT | The size of the metafile in bytes. |
| Version | UINT | The version of the EMF+, EMF or WMF format. |
| EmfPlusFlags | UINT | The EMF+ flags. Bit 0 is set when the metafile was recorded for a display. |
| DpiX, DpiY | Single | The horizontal and vertical resolution of the metafile, in dots per inch. |
| X, Y, Width, Height | Long | The bounds of the metafile in device units. |
| EmfPlusHeaderSize | Long | The size of the EMF+ header in the file. |
| LogicalDpiX, LogicalDpiY | Long | The logical resolution of the reference device context. Usually valid only for EMF+. |
The structure has one more field, which holds the WMF or EMF header and is read through the properties WmfHeader and EmfHeader.
Properties
Bounds
Syntax: r = header.Bounds
Returns X, Y, Width and Height as a GpRect.
IsWmf, IsWmfPlaceable
Syntax: b = header.IsWmf
Syntax: b = header.IsWmfPlaceable
IsWmf is True for a Windows metafile of either kind, and IsWmfPlaceable only for one with a placeable header.
IsEmf, IsEmfOrEmfPlus, IsEmfPlus, IsEmfPlusDual, IsEmfPlusOnly
Syntax: b = header.IsEmf
IsEmf is True for an EMF that has no EMF+ records. IsEmfOrEmfPlus is True for an EMF or either kind of EMF+. IsEmfPlus is True for both kinds of EMF+, IsEmfPlusDual for an EMF+ that also holds the records an EMF reader understands, and IsEmfPlusOnly for one that does not.
IsDisplay
Syntax: b = header.IsDisplay
True for an EMF+ metafile that was recorded for a display device context.
WmfHeader
Syntax: h = header.WmfHeader
Returns the WMF header of a Windows metafile as a structure of the package, or a structure of zeros for another kind of metafile.
EmfHeader
Syntax: h = header.EmfHeader
Returns the EMF header of an EMF or EMF+ metafile as a structure of the package whose fields (nBytes, nRecords, nHandles and others) are those of the Windows ENHMETAHEADER structure, or a structure of zeros for a WMF.
Dim user As GdiPlusUser = GdiPlusUser()
Dim mf As Metafile = Metafile(HeaderEmf.MakeEmf(40, 30), True)
Dim header As MetafileHeader = mf.MetafileHeader
Debug.Print header.Type
Debug.Print header.IsEmf & " " & header.IsEmfOrEmfPlus & " " & header.IsEmfPlus & " " & header.IsWmf
Debug.Print header.X & " " & header.Y & " " & header.Width & " " & header.Height
Debug.Print header.Bounds.Width
Debug.Print header.EmfHeader.nRecords
' Output:
' 3
' True True False False
' 0 0 40 30
' 40
' 3
See Also
- MetafileHeader – Microsoft’s documentation of the GDI+ class
- Metafile class
- WmfPlaceableFileHeader type
- GpMetafileType enumeration