Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than gdi32, prefix the name with the module name and a period.
Please note that this API method needs to be called twice! 1st to get the size of the enh meta file and 2nd to fill the buffer.
Metafile.GetHenhmetafile() should be called only once on the instance. Subsequent calls result with "Parameter is not valid" error.
Tips & Tricks:
Please add some!
Sample Code:
public static byte[] GetEnhMetaFileBits(Metafile mf)
{
ResetLastError(); // sets last error to 0 using [DllImport("kernel32.dll", SetLastError = false)]public static extern int SetLastError(uint dwErrCode);
IntPtr hMf = mf.GetHenhmetafile();
uint bufferSize = GetEnhMetaFileBits(hMf, 0, null); // Get required buffer size specifying 0 and NULL.
if (bufferSize == 0)
{
int lastError = Marshal.GetLastWin32Error();
throw new Exception("GetEnhMetaFileBits failed.", new Win32Exception(lastError));
}
byte[] buffer = new byte[bufferSize];
if (GetEnhMetaFileBits(hMf, bufferSize, buffer) == 0) // Get raw metafile data.
{
int lastError = Marshal.GetLastWin32Error();
throw new Exception("GetEnhMetaFileBits failed.", new Win32Exception(lastError));
}
return buffer;
}
public static byte[] GetEnhMetaFileBits(Metafile mf)
{
ResetLastError();
uint bufferSize = GetEnhMetaFileBits(mf.GetHenhmetafile(), 0, null); // Get required buffer size specifying 0 and NULL.
if (bufferSize == 0)
{
int lastError = Marshal.GetLastWin32Error();
throw new Exception("GetEnhMetaFileBits failed.", new Win32Exception(lastError));
}
byte[] buffer = new byte[bufferSize];
if (GetEnhMetaFileBits(mf.GetHenhmetafile(), bufferSize, buffer) == 0) // Get raw metafile data.
{
int lastError = Marshal.GetLastWin32Error();
throw new Exception("GetEnhMetaFileBits failed.", new Win32Exception(lastError));
}
return buffer;
}
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).