Why does EnumerateMetafile only work with Aero enabled
See the question and my original answer on StackOverflowI don't have a full answer to the "why?" question, but it does not work because you're getting the Graphics
GDI+ object from the Window handle. Instead, you want to get it from a GDI DC, like this:
private void Parse()
{
IntPtr hdc = GetDC(IntPtr.Zero); // get entire screen dc
Graphics graphics = Graphics.FromHdc(hdc));
PointF pointf = new PointF();
graphics.EnumerateMetafile(_metafile, pointf, ParseCallback);
ReleaseDC(IntPtr.Zero, hdc);
}
[DllImport("user32.dll")]
static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("user32.dll")]
static extern IntPtr ReleaseDC(IntPtr hwnd, IntPtr hdc);
Note you could also use the Graphics object from the Form OnPaint(PaintEventArgs e)
method, it should also work, just like in the official sample code for EnumerateMetafile method here: Graphics.EnumerateMetafile Method