void initMshtml() { //don't create in design mode if (this.DesignMode) { return; } if (this.isCreated) { return; //can't create if already created } // force creating Host handle since we need it to parent MSHTML if (!this.IsHandleCreated) { IntPtr hostHandle = Handle; } site = new HtmlSite(this); site.CreateDocument(); if (this.Visible) { site.ActivateDocument(); } else { this.bNeedsActivation = true; this.activateTimer.Enabled = true; } this.mHtmlDoc = (HTMLDocument)site.Document; this.mDocHTML = new DocHTML(mHtmlDoc); if (this.mDesignMode) { IHTMLDocument2 htmldoc = (IHTMLDocument2)this.mHtmlDoc; htmldoc.SetDesignMode("On"); } site.SetPropertyNotifyEvents(); if (url != String.Empty) { LoadUrl(url); } else { //always initialize with at least the blank url LoadUrl("About:Blank"); } if (sDocument != String.Empty) { LoadDocument(sDocument); } else { if (this.mDesignMode) { LoadDocument("<html></html>"); } } }
/// <summary> /// Clean up any resources being used. /// </summary> public void CleanupControl() { if (isCreated) { site.CloseDocument(); site.Dispose(); site = null; this.mHtmlDoc = null; this.mDocHTML = null; } }
/// <summary> /// Clean up any resources being used. /// </summary> public void CleanupControl() { if (isCreated) { sDocument = HtmlDocument2.GetBody().innerHTML; theSite.CloseDocument(); //RP: causes crash, look at this /* if (this.theSite != null) { IntPtr ptr = Marshal.GetIDispatchForObject(this.theSite); int i = Marshal.Release(ptr); while (i > 0) { i = Marshal.Release(ptr); } this.theSite.Dispose(); this.theSite = null; } */ this.mHtmlDoc = null; this.mDocHTML = null; } }