Example #1
0
        //implementation of IServiceProvider

        /*
         * Defines a mechanism for retrieving a service object;
         * that is, an object that provides custom support to other objects
         * */
        public int QueryService(ref Guid guidservice, ref Guid interfacerequested, out IntPtr ppserviceinterface)
        {
            int  hr = HRESULT.E_NOINTERFACE;
            Guid iid_htmledithost  = new Guid("3050f6a0-98b5-11cf-bb82-00aa00bdce0b");
            Guid sid_shtmledithost = new Guid("3050F6A0-98B5-11CF-BB82-00AA00BDCE0B");


            if ((guidservice == sid_shtmledithost) & (interfacerequested == iid_htmledithost))
            {
                CSnap snapper = new CSnap();
                ppserviceinterface = Marshal.GetComInterfaceForObject(snapper, typeof(IHTMLEditHost));
                if (ppserviceinterface != IntPtr.Zero)
                {
                    hr = HRESULT.S_OK;
                }
            }
            else
            {
                ppserviceinterface = IntPtr.Zero;
            }

            return(hr);
        }
Example #2
0
        public void CloseDocument()
        {
            try
            {
                container.releaseWndProc();
                container.Resize -= new EventHandler(this.Container_Resize);

                if (m_document == null) return;

                try
                {
                    //this may raise an exception, however it does work and must
                    //be called
                    if (view != null)
                    {
                        view.Show(-1);
                        view.UIActivate(-1);
                        view.SetInPlaceSite(null);
                        view.CloseView(0);
                    }

                }
                catch (Exception e)
                {
                    Debug.WriteLine("CloseView raised exception: " + e.Message);
                }

                try
                {
                    //this could raise an exception too, but it must be called
                    m_document.Close((int)tagOLECLOSE.OLECLOSE_NOSAVE);
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Close document raised exception: " + e.Message);
                }

                m_document.SetClientSite(null);

                win32.OleLockRunning(m_document, false, false);

                if (this.iAdviseCookie != 0)
                {
                    m_document.Unadvise(this.iAdviseCookie);
                }

                if (this.iEventsCookie != 0)
                {
                    m_document.Unadvise(this.iEventsCookie);
                }

                if (this.iPropertyNotifyCookie != 0)
                {
                    m_document.Unadvise(this.iPropertyNotifyCookie);
                }

                if (container.changeCookie != 0)
                {
                    ((IMarkupContainer2)m_document).UnRegisterForDirtyRange(container.changeCookie);
                    container.changeCookie = 0;
                }

                //release COM objects
                int RefCount = 0;

                if (m_document != null)
                    do
                    {
                        RefCount = Marshal.ReleaseComObject(m_document);
                    } while (RefCount > 0);

                if (view != null)

                    do
                    {
                        RefCount = Marshal.ReleaseComObject(view);
                    } while (RefCount > 0);

                if (activeObject != null)

                    do
                    {
                        RefCount = Marshal.ReleaseComObject(activeObject);
                    } while (RefCount > 0);

                if (snapper != null)
                {
                    IntPtr ppinterface = Marshal.GetComInterfaceForObject(snapper, typeof(IHTMLEditHost));
                    if (ppinterface != null)
                    {
                        do
                        {
                          RefCount = Marshal.Release(ppinterface);
                        } while (RefCount > 0);
                    }
                    snapper = null;
                }
 

                m_document = null;
                view = null;
                activeObject = null;
                container.mHtmlDoc = null;
                container.mDocHTML = null;

            }
            catch (Exception e)
            {
                Debug.WriteLine("CloseDocument raised exception: " + e.Message);

            }
        }
Example #3
0
        public void CloseDocument()
        {
            try
            {
                container.releaseWndProc();
                container.Resize -= new EventHandler(this.Container_Resize);

                if (m_document == null)
                {
                    return;
                }

                try
                {
                    //this may raise an exception, however it does work and must
                    //be called
                    if (view != null)
                    {
                        view.Show(-1);
                        view.UIActivate(-1);
                        view.SetInPlaceSite(null);
                        view.CloseView(0);
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine("CloseView raised exception: " + e.Message);
                }

                try
                {
                    //this could raise an exception too, but it must be called
                    m_document.Close((int)tagOLECLOSE.OLECLOSE_NOSAVE);
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Close document raised exception: " + e.Message);
                }

                m_document.SetClientSite(null);

                win32.OleLockRunning(m_document, false, false);

                if (this.iAdviseCookie != 0)
                {
                    m_document.Unadvise(this.iAdviseCookie);
                }

                if (this.iEventsCookie != 0)
                {
                    m_document.Unadvise(this.iEventsCookie);
                }

                if (this.iPropertyNotifyCookie != 0)
                {
                    m_document.Unadvise(this.iPropertyNotifyCookie);
                }

                if (container.changeCookie != 0)
                {
                    ((IMarkupContainer2)m_document).UnRegisterForDirtyRange(container.changeCookie);
                    container.changeCookie = 0;
                }

                //release COM objects
                int RefCount = 0;

                if (m_document != null)
                {
                    do
                    {
                        RefCount = Marshal.ReleaseComObject(m_document);
                    } while (RefCount > 0);
                }

                if (view != null)
                {
                    do
                    {
                        RefCount = Marshal.ReleaseComObject(view);
                    } while (RefCount > 0);
                }

                if (activeObject != null)
                {
                    do
                    {
                        RefCount = Marshal.ReleaseComObject(activeObject);
                    } while (RefCount > 0);
                }

                if (snapper != null)
                {
                    IntPtr ppinterface = Marshal.GetComInterfaceForObject(snapper, typeof(IHTMLEditHost));
                    if (ppinterface != null)
                    {
                        do
                        {
                            RefCount = Marshal.Release(ppinterface);
                        } while (RefCount > 0);
                    }
                    snapper = null;
                }


                m_document         = null;
                view               = null;
                activeObject       = null;
                container.mHtmlDoc = null;
                container.mDocHTML = null;
            }
            catch (Exception e)
            {
                Debug.WriteLine("CloseDocument raised exception: " + e.Message);
            }
        }
Example #4
0
        //implementation of IServiceProvider
        /*
             * Defines a mechanism for retrieving a service object; 
             * that is, an object that provides custom support to other objects
             * */
        public int QueryService(ref System.Guid guidservice, ref System.Guid interfacerequested, out IntPtr ppserviceinterface)
        {

            int hr = HRESULT.E_NOINTERFACE;
            System.Guid iid_htmledithost = new System.Guid("3050f6a0-98b5-11cf-bb82-00aa00bdce0b");
            System.Guid sid_shtmledithost = new System.Guid("3050F6A0-98B5-11CF-BB82-00AA00BDCE0B");


            if ((guidservice == sid_shtmledithost) & (interfacerequested == iid_htmledithost))
            {
                this.snapper = new CSnap();
                ppserviceinterface = Marshal.GetComInterfaceForObject(snapper, typeof(IHTMLEditHost));
                if (ppserviceinterface != IntPtr.Zero)
                {
                    hr = HRESULT.S_OK;
                }

            }
            else
            {
                ppserviceinterface = IntPtr.Zero;
            }

            return hr;

        }