public int UpdateUI() { if (this.mFullyActive && (this.m_document != null) && (this.container.mDesignMode == true)) { try { mshtml.HTMLDocument thisdoc = (mshtml.HTMLDocument)m_document; //we need IDisplayServices to get the caret position mshtml.IDisplayServices ds = (IDisplayServices)thisdoc; if (ds == null) { return(HRESULT.S_OK); } IHTMLCaret caret; ds.GetCaret(out caret); if (caret == null) { Debug.WriteLine("caret was null"); return(HRESULT.S_OK); } tagPOINT pt = new tagPOINT(); caret.GetLocation(out pt, 1); IHTMLElement el = thisdoc.elementFromPoint(pt.x, pt.y); if (el == null) { Debug.WriteLine("pt was null"); return(HRESULT.S_OK); } container.mcurrentElement = el; container.InvokeUpdateUI(el); } catch (Exception e) { Debug.WriteLine(e.Message + e.StackTrace); } } //should always return S_OK unless error return(HRESULT.S_OK); }