0
我試圖創建一個這樣的增強型圖元:C++中的空文件創建增強型圖元結果
// 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);
接過代碼here
所有我到底得到的是一些0字節非擴展文件的名字很奇怪,像整滅sm sm一樣。
可能是什麼問題?
P.S.另外,我將它稱爲混合模式應用程序,從c#到C++/cli對象。
編輯解決了奇怪編碼的問題,但創建的文件仍然是0字節長度。它如何解決?
@ tube-builder OK我很驚訝,這對我來說似乎是一個很好的解釋。 – john
地獄,我真的很抱歉,沒有注意,現在文件被創建(仍然是空的)。非常感謝! –
btw你有什麼想法爲什麼創建的文件仍然可以是0字節大小?我試圖找到這件事,但迄今爲止失敗了。沒有經驗與C++。 –