Programming magic, glory, and juices.

IHTMLElementRender opacity

June 9th, 2006


Using IHTMLElementRender::DrawToDC is the wrong way to draw the contents of an webpage to a device drawing context. The reason why the IHTMLElementRender interface is not good is because it does not draw opacity or transpancy that might be visible in a web page. Instead it is best to query the IViewObject interface from the IHTMLDocument2 interface and call the function Draw.

BAD
IHTMLDocument2 — IHTMLElement – IHTMLElementRender::DrawToDC.

GOOD
IHTMLDocument2 – IViewObject::Draw using DVASPECT_DOCPRINT

You can also use OleDraw instead of IViewObject::Draw and pass OleDraw the IHTMLDocument2 interface.

4 Responses to “IHTMLElementRender opacity”
  1. Wayne Hoit
     

    I don’t suppose you can help me figure out how to draw an HTML page “into” an Enhanced Metafile using VB 6 ?

  2. Anony
     

    YOU A GENIUS!!!!

  3. Pingback:
    WebBrowser control...again about web sites thumbnails/screenshots generated from the server
  4. Jason Harrison
     

    Is there a solution to the issue that IViewObject::Draw only draws to bitmaps? Even metafile handles result in a bitblt wrapped in a metafile.

Leave a Reply