Exemple #1
0
        /// <include file='doc\MSHTMLHost.uex' path='docs/doc[@for="TridentSite.CloseDocument"]/*' />
        /// <devdoc>
        ///     Closes the mshtml instance by deactivating and releasing it.
        /// </devdoc>
        protected void CloseDocument()
        {
            try {
                if (tridentDocument != null)
                {
                    if (tridentView != null)
                    {
                        tridentView.UIActivate(0);
                        tridentView.SetInPlaceSite(null);
                        tridentView = null;
                    }
                    tridentDocument = null;

                    // Change 1:
                    // After 2 days of investigation... this is all that came out of it (!)...
                    // Calling IOleObject::Close does not seem to work (you guessed it... in the StyleBuilder only)
                    // It causes the app to hang around forever; very bizarre
                    //
                    // Anyway, from Trident sources, they handle the case where a container does not call
                    // Close, and releases references directly
                    //
                    // I thought maybe I should call DoVerb(OLEIVERB_HIDE) at least.
                    // It seems to work, but it theres also some code in trident that says HIDE should not be
                    // called when its running in MsoDocMode. Whats that? For now I am calling it.
                    //
                    // tridentOleObject.Close(NativeMethods.OLECLOSE_NOSAVE);

                    // Change 2:
                    // Furthermore, it looks like I can't call DoVerb(OLEIVERB_HIDE) for docobjects...
                    // We get back E_UNEXPECTED. Apparently the right thing to do is to call
                    // IOleDocumentView::UIActivate(0) and IOleDocumentView::SetInPlaceSite(null)
                    // both of which I am now doing above
                    //
                    // Debug.Assert(parentControl.IsHandleCreated);
                    // NativeMethods.COMRECT r = new NativeMethods.COMRECT();
                    // NativeMethods.GetClientRect(parentControl.Handle, r);
                    //
                    // tridentOleObject.DoVerb(NativeMethods.OLEIVERB_HIDE, IntPtr.Zero, (NativeMethods.IOleClientSite)this, 0,
                    //                         parentControl.Handle, r.ToWin32InteropCOMRECT());

                    tridentOleObject.SetClientSite(null);
                    tridentOleObject = null;
                }
            }
            catch (Exception e) {
                Debug.Fail(e.ToString());
            }
        }
Exemple #2
0
        /// <include file='doc\MSHTMLHost.uex' path='docs/doc[@for="TridentSite.CloseDocument"]/*' />
        /// <devdoc>
        ///     Closes the mshtml instance by deactivating and releasing it.
        /// </devdoc>
        protected void CloseDocument()
        {
            try {
                if (tridentDocument != null)
                {
                    tridentView     = null;
                    tridentDocument = null;

                    tridentOleObject.Close(NativeMethods.OLECLOSE_NOSAVE);
                    tridentOleObject.SetClientSite(null);
                    tridentOleObject = null;
                }
            }
            catch (Exception e) {
                Debug.Fail(e.ToString());
            }
        }
Exemple #3
0
        ///////////////////////////////////////////////////////////////////////////
        // Implementation

        /// <include file='doc\MSHTMLHost.uex' path='docs/doc[@for="TridentSite.CreateDocument"]/*' />
        /// <devdoc>
        ///     Creates a new instance of mshtml and initializes it as a new document
        ///     using its IPersistStreamInit.
        /// </devdoc>
        protected void CreateDocument()
        {
            try {
                // Create an instance of Trident
                tridentDocument  = (NativeMethods.IHTMLDocument2) new NativeMethods.HTMLDocument();
                tridentOleObject = (NativeMethods.IOleObject)tridentDocument;

                // Initialize its client site
                tridentOleObject.SetClientSite((NativeMethods.IOleClientSite) this);

                // Initialize it
                NativeMethods.IPersistStreamInit psi = (NativeMethods.IPersistStreamInit)tridentDocument;
                psi.InitNew();
            }
            catch (Exception e) {
                Debug.Fail(e.ToString());
                throw e;
            }
        }
Exemple #4
0
        /// <include file='doc\MSHTMLHost.uex' path='docs/doc[@for="TridentSite.CreateDocument"]/*' />
        /// <devdoc>
        ///     Creates a new instance of mshtml and initializes it as a new document
        ///     using its IPersistStreamInit.
        /// </devdoc>
        protected void CreateDocument()
        {
            Debug.WriteLineIf(StyleBuilder.StyleBuilderSwitch.TraceVerbose, "In TridentSite::CreateTrident");

            try {
                // Create an instance of Trident
                tridentDocument  = (Microsoft.VisualStudio.Interop.Trident.IHTMLDocument2) new HTMLDocument();
                tridentOleObject = (NativeMethods.IOleObject)tridentDocument;

                // Initialize its client site
                Debug.WriteLineIf(StyleBuilder.StyleBuilderSwitch.TraceVerbose, "Setting Trident's IOleClientSite");
                tridentOleObject.SetClientSite((NativeMethods.IOleClientSite) this);

                // Initialize it
                Debug.WriteLineIf(StyleBuilder.StyleBuilderSwitch.TraceVerbose, "Initializing Trident through IPersistStreamInit");
                NativeMethods.IPersistStreamInit psi = (NativeMethods.IPersistStreamInit)tridentDocument;
                psi.InitNew();
            }
            catch (Exception e) {
                Debug.Fail(e.ToString());
                throw e;
            }
        }
Exemple #5
0
        ///////////////////////////////////////////////////////////////////////////
        // Implementation

        /// <include file='doc\MSHTMLHost.uex' path='docs/doc[@for="TridentSite.CreateDocument"]/*' />
        /// <devdoc>
        ///     Creates a new instance of mshtml and initializes it as a new document
        ///     using its IPersistStreamInit.
        /// </devdoc>
        protected void CreateDocument() {

            try {
                // Create an instance of Trident
                tridentDocument = (NativeMethods.IHTMLDocument2)new NativeMethods.HTMLDocument();
                tridentOleObject = (NativeMethods.IOleObject)tridentDocument;

                // Initialize its client site
                tridentOleObject.SetClientSite((NativeMethods.IOleClientSite)this);

                // Initialize it
                NativeMethods.IPersistStreamInit psi = (NativeMethods.IPersistStreamInit)tridentDocument;
                psi.InitNew();
            }
            catch (Exception e) {
                Debug.Fail(e.ToString());
                throw e;
            }
        }