Exemplo n.º 1
0
        /// <summary>
        /// </summary>
        public void CloseMSHTML()
        {
            hostControl.Resize -= new EventHandler(this.OnParentResize);

            try {
                if (propNotifyCookie != null)
                {
                    propNotifyCookie.Disconnect();
                    propNotifyCookie = null;
                }

                if (tridentDocument != null)
                {
                    tridentView      = null;
                    tridentDocument  = null;
                    tridentCmdTarget = null;
                    activeObject     = null;

                    if (adviseSinkCookie != 0)
                    {
                        tridentOleObject.Unadvise(adviseSinkCookie);
                        adviseSinkCookie = 0;
                    }

                    tridentOleObject.Close(Interop.OLECLOSE_NOSAVE);
                    tridentOleObject.SetClientSite(null);
                    tridentOleObject = null;
                }
            }
            catch (Exception e) {
                Debug.Fail(e.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// </summary>
        public void CreateMSHTML()
        {
            Debug.Assert(tridentDocument == null, "Must call CloseMSHTML before recreating.");

            bool created = false;

            try {
                // create the trident instance
                tridentDocument  = (Interop.IHTMLDocument2) new Interop.HTMLDocument();
                tridentOleObject = (Interop.IOleObject)tridentDocument;

                // hand it our Interop.IOleClientSite implementation
                tridentOleObject.SetClientSite((Interop.IOleClientSite) this);

                created = true;

                propNotifyCookie = new Interop.ConnectionPointCookie(tridentDocument, this, typeof(Interop.IPropertyNotifySink), false);

                tridentOleObject.Advise((Interop.IAdviseSink) this, out adviseSinkCookie);
                Debug.Assert(adviseSinkCookie != 0);

                tridentCmdTarget = (Interop.IOleCommandTarget)tridentDocument;
            }
            finally {
                if (created == false)
                {
                    tridentDocument  = null;
                    tridentOleObject = null;
                    tridentCmdTarget = null;
                }
            }
        }