Windows Metafile Functions & Aldus Placeable MetafilesLast reviewed: July 22, 1997Article ID: Q66949 |
3.00 3.10
WINDOWS
kbprg
The information in this article applies to:
SUMMARYMany Windows-based applications import or export Windows metafiles in a format known as the Aldus Placeable Metafile (APM) format. In this format, these metafiles cannot be used with the Windows metafile functions such as GetMetaFile(), CopyMetaFile(), PlayMetaFile(), etc. To use these metafiles, the APM header must be removed from the metafile and the remaining metafile bits must be written to a newly created metafile.
MORE INFORMATIONThe APM header is 22 bytes in length and is defined as follows: typedef struct { DWORD key; HANDLE hmf; RECT bbox; WORD inch; DWORD reserved; WORD checksum; } APMFILEHEADER;The following code fragment demonstrates how to create a memory-based Windows metafile from an Aldus Placeable Metafile that will work with the metafile functions provided by Windows. More information regarding the APM format is available from the Aldus FAX Info System via a fax machine telephone at (206) 628-5737. It will ask for the document number, which is 9108 for the APM format. It will then ask you to push start on your FAX machine. The Placeable Windows Metafiles are also documented on pages 26-27 of the "Programmer's Reference, Volume 4: Resources" manual from the Windows 3.1 SDK documentation. NOTE: This an open line and no registration fees are required. The phone number for Aldus Technical Information is (206) 628-2040. BOOL RenderAPM (fh) int fh; // a file handle to the APM metafile is passed in{ HANDLE hData; LPSTR lpData; DWORD OffsetToMeta; METAHEADER mfHeader; APMFILEHEADER APMHeader; OffsetToMeta = sizeof(APMHeader); // Seek to beginning of file and read APM header _llseek(fh, 0, 0); if (!_lread(fh, (LPSTR)&APMHeader, sizeof(APMFILEHEADER))) // Error in reading the file return(FALSE); // Return to read metafile header _llseek(fh, OffsetToMeta, 0); if (!_lread(fh, (LPSTR)&mfHeader, sizeof(METAHEADER))) // Error in reading return(FALSE); // Allocate memory for memory based metafile if (!(hData = GlobalAlloc(GHND, (mfHeader.mtSize * 2L)))) return(FALSE); // Were we successful? if (!(lpData = GlobalLock(hData))) { // Error in allocation GlobalFree(hData); return(FALSE); } // Read metafile bits _llseek(fh, OffsetToMeta, 0); if (!_lread(fh, lpData, (mfHeader.mtSize * 2L))) { // Error in reading GlobalUnlock(hData); GlobalFree(hData); return(FALSE); } // Create the METAFILE with the bits we read in. if (!(hMF = SetMetaFileBits(hData))) return(FALSE); GlobalUnlock(hData); // Close the APM file _lclose(fh); // Return success return(TRUE);}
|
Additional reference words: 3.00 3.10 CloseMetaFile CopyMetaFile
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |