I'm trying to create an enhanced metafile like this:
// Obtain a handle to a reference device context.
HDC hdcRef = GetDC(hwnd);
// Determine the picture frame dimensions.
int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE);
int iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE);
int iWidthPels = GetDeviceCaps(hdcRef, HORZRES);
int iHeightPels = GetDeviceCaps(hdcRef, VERTRES);
// Retrieve the coordinates of the client
// rectangle, in pixels.
RECT rect;
GetClientRect(hwnd, &rect);
// Convert client coordinates to .01-mm units.
// Use iWidthMM, iWidthPels, iHeightMM, and
// iHeightPels to determine the number of
// .01-millimeter units per pixel in the x-
// and y-directions.
rect.left = (rect.left * iWidthMM * 100)/iWidthPels;
rect.top = (rect.top * iHeightMM * 100)/iHeightPels;
rect.right = (rect.right * iWidthMM * 100)/iWidthPels;
rect.bottom = (rect.bottom * iHeightMM * 100)/iHeightPels;
// Create the metafile device context.
CreateEnhMetaFile(hdcRef, (LPTSTR)"temp.emf", &rect, NULL);
// Release the reference device context.
ReleaseDC(hwnd, hdcRef);
Took the code here
All I got in the end is some 0 bytes non-extension file with strangely encoded name, smth like 整灭攮晭.
What can be the problem?
P.S. Also, I'm calling it in a mixed-mode app, from c# through a c++/cli object.
EDIT The problem with the strange encoding is solved, but the file created is still 0 bytes length. How can it be solved?