title: How to render HTML element without using web browser?
body: <p>Is there a way how to draw specific HTML element content on a canvas without using any web browser control ?</p>
  
  <p>With this code I'm rendering the element to the form's canvas (just as an example).<br>
  It works though, but this code is not a good practice - see below, why...</p>
  
  <pre><code>uses
    SHDocVw, MSHTML;
  
  procedure TForm1.Button1Click(Sender: TObject);
  var
    WebBrowser: TWebBrowser;
    HTMLElement: IHTMLElement;
    HTMLRenderer: IHTMLElementRender;
  begin
    WebBrowser := TWebBrowser.Create(nil);
    try
      WebBrowser.ParentWindow := Application.Handle;
      WebBrowser.Navigate('https://stackoverflow.com/questions/2975586/good-delphi-blogs');
  
      while WebBrowser.ReadyState &lt; READYSTATE_COMPLETE do
        Application.ProcessMessages;
  
      HTMLElement := (WebBrowser.Document as IHTMLDocument3).getElementById('question');
      HTMLRenderer := (HTMLElement as IHTMLElementRender);
      HTMLRenderer.DrawToDC(Canvas.Handle);
  
    finally
      HTMLElement := nil;
      HTMLRenderer := nil;
      WebBrowser.Free;
    end;
  end;
  </code></pre>
  
  <p>It's bad because</p>
  
  <ul>
  <li>it uses the hidden <a href="http://docwiki.embarcadero.com/VCL/en/SHDocVw.TWebBrowser" rel="nofollow noreferrer">TWebBrowser</a> control, but I would like to load the HTML document directly through the <a href="http://msdn.microsoft.com/en-us/library/aa752574%28v=VS.85%29.aspx" rel="nofollow noreferrer">IHTMLDocument</a> interface and render certain element on my own canvas</li>
  <li>if I create and load the <a href="http://msdn.microsoft.com/en-us/library/aa752574%28v=VS.85%29.aspx" rel="nofollow noreferrer">IHTMLDocument</a> manually e.g. <a href="https://stackoverflow.com/a/2483393/960757">this way</a> then the renderer method <a href="http://msdn.microsoft.com/en-us/library/aa752273%28v=vs.85%29.aspx" rel="nofollow noreferrer">IHTMLElementRender.DrawToDC</a> doesn't paint anything (maybe because there's no canvas for rendering of the document)</li>
  <li>even worse is that <a href="http://msdn.microsoft.com/en-us/library/aa752273%28v=vs.85%29.aspx" rel="nofollow noreferrer">IHTMLElementRender.DrawToDC</a> is deprecated at this time, so I'm looking for an alternative method for rendering elements on my own canvas</li>
  </ul>
  
  <p>Is there a clean way to solve this using MSHTML ?</p>