views:

17

answers:

2

I have been using the following code to get a metafile vector image for the content of IWebBrowser2 control as following:

IHTMLElement* pDocBody;

IHTMLDocument2* pDoc;

... ...

pDoc->get_body(&pDocBody); // get body element for IHTMLDocument2

pDocBody->get_parentElement(&pEleParent); pEleParent->QueryInterface(IID_IHTMLElement2,(void**)&pRenderEle2); // get the element to render from

pRenderEle2->QueryInterface(IID_IHTMLElementRender,(void**)&pRender); // get the render interface

HDC hMetaDC=::CreateEnhMetaFile(hRefDC,PictFile,&MetaRect,NULL); // get DC

hr = pRender->DrawToDC(hMetaDC);

The code above had worked beautifully with IE6, IE7, IE8 to provide for vector image for the browser content. But the DrawToDC call above fails with the Beta release of IE9 (testing on Windows 7, 32 bit) with error code: 0x8007000e .

I have tried to use WM_PRINT and other draw methods but I am only able to get the bitmap image, not the vector image.

Any idea why DrawToDC fail with IE9 in the code above, and if there is any other method of getting vector image with IE9.

Thanks, Subhash

+2  A: 

This is just a guess. IE9 touts faster rendering through hardware acceleration. I suspect that they're bypassing GDI and using something more direct like the new DirectWrite and/or Direct2D APIs. Metafiles are basically a serialization of GDI calls. Without GDI calls, there's not much to capture there. So you may be out of luck. :-(

Adrian McCarthy
A: 

Thanks, I was afraid this might be the case. Do you know if there is a method available to switch IE9 rendering to GDI mode temporarily. I expect this to reduce the rendering quality/efficiency, which I should be able to live with in my current application.

Subhash Bhardwaj