Пример #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());
            }
        }
Пример #2
0
        ///////////////////////////////////////////////////////////////////////////
        // IOleDocumentSite Implementation

        public virtual int ActivateMe(NativeMethods.IOleDocumentView pViewToActivate)
        {
            Debug.Assert(pViewToActivate != null,
                         "Expected the view to be non-null");
            if (pViewToActivate == null)
            {
                return(NativeMethods.E_INVALIDARG);
            }

            NativeMethods.COMRECT r = new NativeMethods.COMRECT();

            NativeMethods.GetClientRect(parentControl.Handle, r);

            tridentView = pViewToActivate;
            tridentView.SetInPlaceSite((NativeMethods.IOleInPlaceSite) this);
            tridentView.UIActivate(1);
            tridentView.SetRect(r);
            tridentView.Show(1);

            return(NativeMethods.S_OK);
        }
Пример #3
0
        ///////////////////////////////////////////////////////////////////////////
        // IOleDocumentSite Implementation

        public virtual int ActivateMe(NativeMethods.IOleDocumentView pViewToActivate)
        {
            Debug.WriteLineIf(StyleBuilder.StyleBuilderSwitch.TraceVerbose, "CTridentSite: IOleDocumentSite::ActivateMe");

            Debug.Assert(pViewToActivate != null,
                         "Expected the view to be non-null");
            if (pViewToActivate == null)
            {
                return(NativeMethods.E_INVALIDARG);
            }
            //throw new COMException(String.Empty, NativeMethods.E_INVALIDARG);

            NativeMethods.COMRECT r = new NativeMethods.COMRECT();

            NativeMethods.GetClientRect(parentControl.Handle, r);

            tridentView = pViewToActivate;
            tridentView.SetInPlaceSite((NativeMethods.IOleInPlaceSite) this);
            tridentView.UIActivate(1);
            tridentView.SetRect(r.ToWin32InteropCOMRECT());
            tridentView.Show(1);

            return(NativeMethods.S_OK);
        }
Пример #4
0
        ///////////////////////////////////////////////////////////////////////////
        // IOleDocumentSite Implementation

        public virtual int ActivateMe(NativeMethods.IOleDocumentView pViewToActivate) {
            Debug.Assert(pViewToActivate != null,
                         "Expected the view to be non-null");
            if (pViewToActivate == null)
                return NativeMethods.E_INVALIDARG;

            NativeMethods.COMRECT r = new NativeMethods.COMRECT();

            NativeMethods.GetClientRect(parentControl.Handle, r);

            tridentView = pViewToActivate;
            tridentView.SetInPlaceSite((NativeMethods.IOleInPlaceSite)this);
            tridentView.UIActivate(1);
            tridentView.SetRect(r);
            tridentView.Show(1);

            return NativeMethods.S_OK;
        }