Esempio 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());
            }
        }
Esempio n. 2
0
 public int ActivateMe(Interop.IOleDocumentView pViewToActivate)
 {
     if (pViewToActivate == null)
     {
         return -2147024809;
     }
     Interop.COMRECT rect = new Interop.COMRECT();
     Interop.GetClientRect(this.hostControl.Handle, rect);
     this.tridentView = pViewToActivate;
     this.tridentView.SetInPlaceSite(this);
     this.tridentView.UIActivate(1);
     this.tridentView.SetRect(rect);
     this.tridentView.Show(1);
     return 0;
 }
Esempio n. 3
0
        public int ActivateMe(Interop.IOleDocumentView pViewToActivate)
        {
            if (pViewToActivate == null)
            {
                return(Interop.E_INVALIDARG);
            }

            Interop.RECT r = EditorRect;

            interopDocumentView = pViewToActivate;
            interopDocumentView.SetInPlaceSite(this);
            interopDocumentView.UIActivate(WithUI ? 1 : 0);
            interopDocumentView.SetRect(r);
            interopDocumentView.Show(1);

            return(Interop.S_OK);
        }
Esempio n. 4
0
        ///////////////////////////////////////////////////////////////////////////
        // Interop.IOleDocumentSite Implementation

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

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

            Interop.GetClientRect(hostControl.Handle, r);

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

            return(Interop.S_OK);
        }
Esempio n. 5
0
 public void CloseMSHTML()
 {
     this.hostControl.Resize -= new EventHandler(this.OnParentResize);
     try
     {
         if (this.propNotifyCookie != null)
         {
             this.propNotifyCookie.Disconnect();
             this.propNotifyCookie = null;
         }
         if (this.tridentDocument != null)
         {
             this.tridentView = null;
             this.tridentDocument = null;
             this.tridentCmdTarget = null;
             this.activeObject = null;
             if (this.adviseSinkCookie != 0)
             {
                 this.tridentOleObject.Unadvise(this.adviseSinkCookie);
                 this.adviseSinkCookie = 0;
             }
             this.tridentOleObject.Close(1);
             this.tridentOleObject.SetClientSite(null);
             this.tridentOleObject = null;
         }
     }
     catch (Exception)
     {
     }
 }
Esempio n. 6
0
 /// <summary>
 /// </summary>
 public void Dispose()
 {
     try
     {
         int RefCount;
         if (propNotifyCookie != null)
         {
             propNotifyCookie.Dispose();
             propNotifyCookie = null;
         }
         if (winEvents != null)
         {
             winEvents.Dispose();
             winEvents = null;
         }
         try
         {
             Marshal.ReleaseComObject(window);
         }
         catch
         {
         }
         try
         {
             if (interopDocumentView != null)
             {
                 try
                 {
                     interopDocumentView.Show(0);
                 }
                 catch
                 {
                 }
                 try
                 {
                     interopDocumentView.UIActivate(0);
                 }
                 catch
                 {
                 }
                 try
                 {
                     interopDocumentView.SetInPlaceSite(null);
                 }
                 catch
                 {
                 }
                 long nullParam = 0L;
                 try
                 {
                     interopDocumentView.Close(nullParam);
                     do
                     {
                         RefCount = Marshal.ReleaseComObject(interopDocumentView);
                     } while (RefCount >= 0);
                 }
                 catch
                 {
                 }
                 finally
                 {
                     Marshal.FinalReleaseComObject(interopDocumentView);
                     interopDocumentView = null;
                 }
             }
         }
         catch
         {
         }
         if (oleDocumentObject != null)
         {
             try
             {
                 if (htmlEditor.Site == null || !htmlEditor.Site.DesignMode)
                 {
                     Marshal.FinalReleaseComObject(oleDocumentObject);
                     oleDocumentObject = null;
                 }
             }
             catch
             {
             }
         }
         if (htmlbaseDocument != null)
         {
             do
             {
                 RefCount = Marshal.ReleaseComObject(htmlbaseDocument);
             } while (RefCount >= 0);
             Marshal.FinalReleaseComObject(htmlbaseDocument);
             htmlbaseDocument = null;
         }
         if (interopDocumentView != null)
         {
             do
             {
                 RefCount = Marshal.ReleaseComObject(interopDocumentView);
             } while (RefCount >= 0);
         }
         if (activeObject != null)
         {
             do
             {
                 RefCount = Marshal.ReleaseComObject(activeObject);
             } while (RefCount >= 0);
             Marshal.FinalReleaseComObject(activeObject);
             activeObject = null;
         }
         interopDocumentView = null;
         htmlbaseDocument    = null;
         activeObject        = null;
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }