Problems with the Draw() on the IHMTLPainter interface

Friday, October 06, 2006 1:24:29 PM (Central Standard Time, UTC-06:00)

The project that I am working on right now we are making some customizations to the MSHTML editor that is hosted by Internet Explorer.  With that we have some custom tags that we need rendered in a specific way (for example wavy lines under misspelled words). 

This can be accomplished by a Binary Behavior that implements the IHTMLPainter interface.  When the behavior is loaded, MSHTML checks to see if the IHTMLPainter interface is supported, if it is supported it will call the appropriate methods on the interface to render the tag. 

The problem I was having was the Draw method was never called.  I could attach the behavior to the body tag and it would render the graphics I wanted, but as soon as a moved it to a span it wouldn't call the draw.  After a couple of hours playing around with it I finally stumbled on to the fact that if the span has a height and width set (even to 0) the Draw() method will be called.  I didn't find this documented anywhere so I thought I would post it for others.

Learn more about binary behaviors here.