| | | | Browse by category |
Problem
The metafiles generated by Objective Grid are not read by some applications including Word 6. Why does this happen?
Cause
These applications expect the .wmf file to have a placeable header.
Action
The code for adding this header is as below:
// .h file
typedef struct tagOLDRECT |
|||
short left; short top; short right; short bottom; |
|||
} OLDRECT;
typedef struct |
|||
DWORD key; WORD hmf; OLDRECT bbox; WORD inch; DWORD reserved; WORD checksum; |
|||
} ALDUSMFHEADER;
// .cpp file #define ALDUSSIZE 22 BOOL CServ3View::WriteMetaFileAsPlaceable(HMETAFILE hMetaFile, LPCTSTR lpstrOutFileName) |
|||
HANDLE hOutFile; ALDUSMFHEADER APMFileHeader; METAHEADER mh; // Fill out the placeable header // Get the bits // Open the file |
|||
lpstrOutFileName, // pointer to name of the file GENERIC_WRITE, // access (read-write) mode 0, // share mode NULL, // pointer to security descriptor CREATE_ALWAYS, // how to create FILE_ATTRIBUTE_NORMAL, // file attributes NULL // handle to file with attributes to copy ); |
|||
if(!hOutFile) | |||
return FALSE; | |||
DWORD dwNumBytes;
// Write the header |
|||
CloseHandle((HANDLE)hOutFile); AfxMessageBox(_T("1 write fails")); return FALSE; |
|||
}
// Write the header if (!WriteFile((HANDLE)hOutFile, (void*)&mh, sizeof(mh), &dwNumBytes, NULL)) |
|||
CloseHandle( (HANDLE)hOutFile ); AfxMessageBox(_T("1 write fails")); return FALSE; |
|||
}
pBuffer +=METASIZE; // Write the bits |
|||
CloseHandle((HANDLE)hOutFile); AfxMessageBox(_T("2 write fails")); return FALSE; |
|||
}
// Close the file // clean up return TRUE; |
|||
}
WORD CServ3View::CalculateAPMCheckSum(ALDUSMFHEADER apmfh) |
|||
LPWORD lpWord; WORD wResult, i; // Start with the first word // XOR in each of the other 9 words |
|||
wResult ^= lpWord[i]; | |||
}
return wResult; |
|||
} |