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
        /// <summary>
        /// </summary>
        public void CreateMSHTML()
        {
            bool created = false;

            try
            {
                // create our base instance
                this.htmlbaseDocument = (Interop.IHTMLDocument2) new Interop.HTMLDocument();

                this.activeObject = (Interop.IOleInPlaceActiveObject)htmlbaseDocument;
                this.windowHandle = new IntPtr();
                this.activeObject.GetWindow(out this.windowHandle);

                oleDocumentObject = (Interop.IOleObject)htmlbaseDocument;
                if (oleDocumentObject == null)
                {
                    throw new ApplicationException("InteropOleObject not created. No document available.");
                }
                // hand it our Interop.IOleClientSite implementation
                Win32.OleRun(htmlbaseDocument);
                oleDocumentObject.SetClientSite(this);
                Win32.OleLockRunning(htmlbaseDocument, true, false);
                created = true;
                // attach document and window base events
                propNotifyCookie = new ConnectionPointCookie(htmlbaseDocument, this, typeof(Interop.IPropertyNotifySink), false);
                // set document properties
                oleDocumentObject.SetHostNames("NetRix", "NetRix");
                // set ole events
                oleDocumentObject.Advise(this, out adviseSinkCookie);
                // set
                IConnectionPointContainer icpc = (IConnectionPointContainer)htmlbaseDocument;
                //find the source interface
                ////get IPropertyNotifySink interface
                //Guid g = new Guid("9BFBBC02-EFF1-101A-84ED-00AA00341D07");
                //icpc.FindConnectionPoint(ref g, out icp);
                ////pass a pointer to the host to the connection point
                //icp.Advise(this._site, out this._cookie);
            }
            catch (Exception ex)
            {
                Debug.Fail("CreateHtml failed", ex.Message);
            }
            finally
            {
                if (created == false)
                {
                    htmlbaseDocument  = null;
                    oleDocumentObject = null;
                }
            }
        }
Esempio n. 3
0
 void Interop.IOleInPlaceFrame.SetActiveObject(Interop.IOleInPlaceActiveObject pActiveObject, string pszObjName)
 {
     try {
         if (pActiveObject == null)
         {
             if (this.activeObject != null)
             {
                 Marshal.ReleaseComObject(this.activeObject);
             }
             this.activeObject = null;
             this.windowHandle = IntPtr.Zero;
         }
         else
         {
             this.activeObject = pActiveObject;
             this.windowHandle = new IntPtr();
             pActiveObject.GetWindow(out this.windowHandle);
         }
     }
     catch {
     }
 }
Esempio n. 4
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. 5
0
 public void SetActiveObject(Interop.IOleInPlaceActiveObject pActiveObject, string pszObjName)
 {
     this.activeObject = pActiveObject;
 }
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);
     }
 }
Esempio n. 7
0
 public int ShowUI(int dwID, Interop.IOleInPlaceActiveObject activeObject, Interop.IOleCommandTarget commandTarget, Interop.IOleInPlaceFrame frame, Interop.IOleInPlaceUIWindow doc)
 {
     return(Interop.S_OK);
 }
Esempio n. 8
0
 public void SetActiveObject(Interop.IOleInPlaceActiveObject pActiveObject, string pszObjName)
 {
     this.activeObject = pActiveObject;
 }
Esempio n. 9
0
 int Interop.IOleInPlaceSite.OnInPlaceDeactivate()
 {
     activeObject = null;
     return(Interop.S_OK);
 }