Esempio n. 1
0
 public virtual void CloseDW(uint dwReserved)
 {
     fClosedDW = true;
     ShowDW(false);
     Dispose(true);
     if (Explorer != null)
     {
         Marshal.ReleaseComObject(Explorer);
         Explorer = null;
     }
     if (BandObjectSite != null)
     {
         Marshal.ReleaseComObject(BandObjectSite);
         BandObjectSite = null;
     }
     if (RebarSubclass != null)
     {
         RebarSubclass.ReleaseHandle();
         RebarSubclass = null;
     }
     if (RebarSubclass != null)
     {
         RebarSubclass.ReleaseHandle();
         RebarSubclass = null;
     }
 }
Esempio n. 2
0
 public virtual void SetSite(object pUnkSite)
 {
     if (this.BandObjectSite != null)
     {
         Marshal.ReleaseComObject(this.BandObjectSite);
     }
     if (this.Explorer != null)
     {
         Marshal.ReleaseComObject(this.Explorer);
         this.Explorer = null;
     }
     this.BandObjectSite = pUnkSite as IInputObjectSite;
     if (this.BandObjectSite != null)
     {
         Guid guid = ExplorerGUIDs.IID_IWebBrowserApp;
         Guid riid = ExplorerGUIDs.IID_IUnknown;
         try {
             object obj2;
             ((_IServiceProvider)this.BandObjectSite).QueryService(ref guid, ref riid, out obj2);
             this.Explorer = (WebBrowserClass)Marshal.CreateWrapperOfType(obj2 as IWebBrowser, typeof(WebBrowserClass));
             this.OnExplorerAttached();
         }
         catch (COMException) {
         }
     }
     try {
         BandObjectLib.IOleWindow window = pUnkSite as BandObjectLib.IOleWindow;
         if (window != null)
         {
             window.GetWindow(out this.ReBarHandle);
         }
     }
     catch {
     }
 }
Esempio n. 3
0
        public void SetSite([In, MarshalAs(UnmanagedType.IUnknown)] Object pUnkSite)
        {
            if (DeskBandSite != null)
            {
                Marshal.ReleaseComObject(DeskBandSite);
            }

            DeskBandSite = (IInputObjectSite)pUnkSite;
        }
Esempio n. 4
0
        int IObjectWithSite.SetSite(object pUnkSite)
        {
            //  Log key events.
            Log("IObjectWithSite.SetSite called.");

            //  If we have a site, free it. This won't actually release the COM
            //  interface until garbage collection happens.
            inputObjectSite = null;

            //  If we have not been provided a site, the band is being removed.
            if (pUnkSite == null)
            {
                Log("IObjectWithSite.SetSite pUnkSite == null");
                OnBandRemoved();
                if (lazyDeskBand.IsValueCreated)
                {
                    lazyDeskBand.Value.Hide();
                    User32.SetParent(lazyDeskBand.Value.Handle, IntPtr.Zero);
                    lazyDeskBand.Value.Dispose();
                    lazyDeskBand = new Lazy <UserControl>(CreateDeskBand);
                }
                return(WinError.S_OK);
            }

            //  We've been given a site, that means we can get the site window.
            try
            {
                Log("IObjectWithSite.SetSite try");
                //  Get the OLE window.
                var oleWindow = (IOleWindow)pUnkSite;

                //  Get the parent window handle.
                if (oleWindow.GetWindow(out parentWindowHandle) != WinError.S_OK)
                {
                    LogError("Failed to get the handle to the site window.");
                    return(WinError.E_FAIL);
                }

                //  Create the desk band user interface by getting the lazy band.
                var band = lazyDeskBand.Value;

                //  Set the parent.
                User32.SetParent(band.Handle, parentWindowHandle);
                Log("IObjectWithSite.SetSite try end");
            }
            catch (Exception exception)
            {
                LogError("Failed to cast the provided site to an IOleWindow.", exception);
                return(WinError.E_FAIL);
            }

            //  Store the input site.
            inputObjectSite = (IInputObjectSite)pUnkSite;

            return(WinError.S_OK);
        }
Esempio n. 5
0
        public override void Release()
        {
            base.Release();

            if (m_pIInputObjectSite != null)
            {
                Marshal.ReleaseComObject(m_pIInputObjectSite);
                m_pIInputObjectSite = null;
            }
        }
Esempio n. 6
0
        public virtual void SetSite(Object pUnkSite)
        {
            if (inputObjectSite != null)
            {
                Marshal.ReleaseComObject(inputObjectSite);
            }

            if (webBrowserClass != null)
            {
                Marshal.ReleaseComObject(webBrowserClass);
                webBrowserClass = null;
            }

            inputObjectSite = (IInputObjectSite)pUnkSite;

            if (inputObjectSite != null)
            {
                //pUnkSite is a pointer to object that implements IOleWindowSite or something  similar
                //we need to get access to the top level object - explorer itself
                //to allows this explorer objects also implement IServiceProvider interface
                //(don't mix it with System.IServiceProvider!)
                //we get this interface and ask it to find WebBrowserApp
                _IServiceProvider sp = inputObjectSite as _IServiceProvider;
                Guid guid            = ExplorerGUIDs.IID_IWebBrowserApp;
                Guid riid            = ExplorerGUIDs.IID_IUnknown;

                try
                {
                    object w;
                    sp.QueryService(ref guid, ref riid, out w);

                    //once we have interface to the COM object we can create RCW from it
                    webBrowserClass = (WebBrowserClass)Marshal.CreateWrapperOfType(w as IWebBrowser, typeof(WebBrowserClass));

                    if (SetSiteEvent != null)
                    {
                        SetSiteEvent(pUnkSite);
                    }
                }
                catch (COMException)
                {
                    //we anticipate this exception in case our object instantiated
                    //as a Desk Band. There is no web browser service available.
                }
            }
            else
            {
                if (SetSiteEvent != null)
                {
                    SetSiteEvent(pUnkSite);
                }
            }
        }
Esempio n. 7
0
        int IObjectWithSite.SetSite(object pUnkSite)
        {
            //  Log key events.
            Log("IObjectWithSite.SetSite called.");

            //  If we have a site, free it. This won't actually release the COM
            //  interface until garbage collection happens.
            inputObjectSite = null;

            //  If we have not been provided a site, the band is being removed.
            if (pUnkSite == null)
            {
                OnBandRemoved();
                if (lazyDeskBand.IsValueCreated)
                {
                    lazyDeskBand.Value.Hide();
                    User32.SetParent(lazyDeskBand.Value.Handle, IntPtr.Zero);
                    lazyDeskBand.Value.Dispose();
                    lazyDeskBand = new Lazy<UserControl>(CreateDeskBand);
                }
                return WinError.S_OK;
            }

            //  We've been given a site, that means we can get the site window.
            try
            {
                //  Get the OLE window.
                var oleWindow = (IOleWindow)pUnkSite;

                //  Get the parent window handle.
                if (oleWindow.GetWindow(out parentWindowHandle) != WinError.S_OK)
                {
                    LogError("Failed to get the handle to the site window.");
                    return WinError.E_FAIL;
                }

                //  Create the desk band user interface by getting the lazy band.
                var band = lazyDeskBand.Value;

                //  Set the parent.
                User32.SetParent(band.Handle, parentWindowHandle);
            }
            catch(Exception exception)
            {
                LogError("Failed to cast the provided site to an IOleWindow.", exception);
                return WinError.E_FAIL;
            }

            //  Store the input site.
            inputObjectSite = (IInputObjectSite)pUnkSite;

            return WinError.S_OK;
        }
Esempio n. 8
0
        public virtual void SetSite(Object pUnkSite)
        {
            if (BandObjectSite != null)
            {
                Marshal.ReleaseComObject(BandObjectSite);
            }

            if (Explorer != null)
            {
                Marshal.ReleaseComObject(Explorer);
                Explorer = null;
            }

            BandObjectSite = (IInputObjectSite)pUnkSite;
            if (BandObjectSite != null)
            {
                //pUnkSite is a pointer to object that implements IOleWindowSite or something  similar
                //we need to get access to the top level object - explorer itself
                //to allows this explorer objects also implement IServiceProvider interface
                //(don't mix it with System.IServiceProvider!)
                //we get this interface and ask it to find WebBrowserApp
                _IServiceProvider sp = BandObjectSite as _IServiceProvider;
                Guid guid            = ExplorerGUIDs.IID_IWebBrowserApp;
                Guid riid            = ExplorerGUIDs.IID_IUnknown;

                try
                {
                    object w;
                    sp.QueryService(
                        ref guid,
                        ref riid,
                        out w);

                    //once we have interface to the COM object we can create RCW from it
                    //Error	8	Interop type 'SHDocVw.WebBrowserClass' cannot be embedded. Use the applicable interface instead.
                    Explorer = (WebBrowserClass)Marshal.CreateWrapperOfType(
                        w as IWebBrowser,
                        typeof(WebBrowserClass)
                        );


                    OnExplorerAttached(EventArgs.Empty);
                }
                catch (COMException)
                {
                    //we anticipate this exception in case our object instantiated
                    //as a Desk Band. There is no web browser service available.
                }
            }
        }
Esempio n. 9
0
 public virtual void SetSite(Object pUnkSite)
 {
     if (BandObjectSite != null)
     {
         Marshal.ReleaseComObject(BandObjectSite);
     }
     if (_Explorer != null)
     {
         Marshal.ReleaseComObject(_Explorer);
         _Explorer = null;
     }
     BandObjectSite = (IInputObjectSite)pUnkSite;
     QueryExplorerWindow();
 }
Esempio n. 10
0
 public virtual void SetSite(object pUnkSite)
 {
     if (this.BandObjectSite != null)
     {
         Marshal.ReleaseComObject(this.BandObjectSite);
     }
     if (this.Explorer != null)
     {
         Marshal.ReleaseComObject(this.Explorer);
         this.Explorer = null;
     }
     this.BandObjectSite = (IInputObjectSite)pUnkSite;
     if (this.BandObjectSite != null)
     {
         this.QueryExplorerWindow();
     }
 }
Esempio n. 11
0
 public virtual void CloseDW(uint dwReserved)
 {
     fClosedDW = true;
     ShowDW(false);
     Dispose(true);
     if(Explorer != null) {
         Marshal.ReleaseComObject(Explorer);
         Explorer = null;
     }
     if(BandObjectSite != null) {
         Marshal.ReleaseComObject(BandObjectSite);
         BandObjectSite = null;
     }
     if(RebarSubclass != null) {
         RebarSubclass.Enabled = false;
         RebarSubclass = null;
     }
 }
Esempio n. 12
0
 //IObjectWithSite.SetSite
 public virtual void SetSite(object pUnkSite)
 {
     if (Process.GetCurrentProcess().ProcessName == "iexplore")
     {
         Marshal.ThrowExceptionForHR(E_FAIL);
     }
     if (BandObjectSite != null)
     {
         Marshal.ReleaseComObject(BandObjectSite);
     }
     if (Explorer != null)
     {
         Marshal.ReleaseComObject(Explorer);
         Explorer = null;
     }
     BandObjectSite = pUnkSite as IInputObjectSite;
     if (BandObjectSite != null)
     {
         try
         {
             object obj2;
             ((_IServiceProvider)BandObjectSite).QueryService(ExplorerGUIDs.IID_IWebBrowserApp, ExplorerGUIDs.IID_IUnknown, out obj2);
             Explorer = (WebBrowserClass)Marshal.CreateWrapperOfType(obj2 as IWebBrowser, typeof(WebBrowserClass));
             OnExplorerAttached();
         }
         catch (COMException)
         { // exception
           // QTUtility2.MakeErrorLog(exception, "MSG:" + exception.Message);
         }
     }
     try
     {
         IOleWindow window = pUnkSite as IOleWindow;
         if (window != null)
         {
             window.GetWindow(out ReBarHandle);
         }
     }
     catch (Exception) // exc
     {
         //  logger.Log(exc);
     }
 }
Esempio n. 13
0
        public override void SetSite(Object pUnkSite)
        {
            SetSiteResults doOnSetSite = base.SetSiteWithStatus(pUnkSite);

            if (doOnSetSite != SetSiteResults.Success)
            {
                return;
            }

            if (m_pIInputObjectSite != null)
            {
                Release();
            }

            if (pUnkSite == null)
            {
                return;
            }

            m_pIInputObjectSite = pUnkSite as IInputObjectSite;
        }
Esempio n. 14
0
 public virtual void SetSite(object pUnkSite)
 {
     if (Process.GetCurrentProcess().ProcessName == "iexplore")
     {
         Marshal.ThrowExceptionForHR(E_FAIL);
     }
     if (BandObjectSite != null)
     {
         Marshal.ReleaseComObject(BandObjectSite);
     }
     if (Explorer != null)
     {
         Marshal.ReleaseComObject(Explorer);
         Explorer = null;
     }
     BandObjectSite = pUnkSite as IInputObjectSite;
     if (BandObjectSite != null)
     {
         Guid guid = ExplorerGUIDs.IID_IWebBrowserApp;
         Guid riid = ExplorerGUIDs.IID_IUnknown;
         try {
             object obj2;
             ((_IServiceProvider)BandObjectSite).QueryService(ref guid, ref riid, out obj2);
             Explorer = (WebBrowserClass)Marshal.CreateWrapperOfType(obj2 as IWebBrowser, typeof(WebBrowserClass));
             OnExplorerAttached();
         }
         catch (COMException) {
         }
     }
     try {
         IOleWindow window = pUnkSite as IOleWindow;
         if (window != null)
         {
             window.GetWindow(out ReBarHandle);
         }
     }
     catch {
     }
 }
Esempio n. 15
0
 public virtual void SetSite(object pUnkSite) {
     if(Process.GetCurrentProcess().ProcessName == "iexplore") {
         Marshal.ThrowExceptionForHR(E_FAIL);
     }
     if(BandObjectSite != null) {
         Marshal.ReleaseComObject(BandObjectSite);
     }
     if(Explorer != null) {
         Marshal.ReleaseComObject(Explorer);
         Explorer = null;
     }
     BandObjectSite = pUnkSite as IInputObjectSite;
     if(BandObjectSite != null) {
         Guid guid = ExplorerGUIDs.IID_IWebBrowserApp;
         Guid riid = ExplorerGUIDs.IID_IUnknown;
         try {
             object obj2;
             ((_IServiceProvider)BandObjectSite).QueryService(ref guid, ref riid, out obj2);
             Explorer = (WebBrowserClass)Marshal.CreateWrapperOfType(obj2 as IWebBrowser, typeof(WebBrowserClass));
             OnExplorerAttached();
         }
         catch(COMException) {
         }
     }
     try {
         IOleWindow window = pUnkSite as IOleWindow;
         if(window != null) {
             window.GetWindow(out ReBarHandle);
         }
     }
     catch {
     }
 }
Esempio n. 16
0
        public virtual void SetSite(Object pUnkSite)
        {
            if (BandObjectSite != null)
                Marshal.ReleaseComObject(BandObjectSite);

            if (Explorer != null)
            {
                Marshal.ReleaseComObject(Explorer);
                Explorer = null;
            }

            BandObjectSite = (IInputObjectSite)pUnkSite;
            if (BandObjectSite != null)
            {
                //pUnkSite is a pointer to object that implements IOleWindowSite or something  similar
                //we need to get access to the top level object - explorer itself
                //to allows this explorer objects also implement IServiceProvider interface
                //(don't mix it with System.IServiceProvider!)
                //we get this interface and ask it to find WebBrowserApp
                _IServiceProvider sp = BandObjectSite as _IServiceProvider;
                Guid guid = ExplorerGUIDs.IID_IWebBrowserApp;
                Guid riid = ExplorerGUIDs.IID_IUnknown;

                try
                {
                    object w;
                    sp.QueryService(
                        ref guid,
                        ref riid,
                        out w);

                    //once we have interface to the COM object we can create RCW from it
                    Explorer = (WebBrowserClass)Marshal.CreateWrapperOfType(
                        w as IWebBrowser,
                        typeof(WebBrowserClass)
                        );

                    OnExplorerAttached(EventArgs.Empty);
                }
                catch (COMException)
                {
                    //we anticipate this exception in case our object instantiated
                    //as a Desk Band. There is no web browser service available.
                }
            }
        }
Esempio n. 17
0
 public virtual void CloseDW(uint dwReserved) {
     this.fClosedDW = true;
     this.ShowDW(false);
     this.Dispose(true);
     if(this.Explorer != null) {
         Marshal.ReleaseComObject(this.Explorer);
         this.Explorer = null;
     }
     if(this.BandObjectSite != null) {
         Marshal.ReleaseComObject(this.BandObjectSite);
         this.BandObjectSite = null;
     }
     if(this.RebarSubclass != null) {
         this.RebarSubclass.ReleaseHandle();
         RebarSubclass = null;
     }
     if(RebarSubclass != null) {
         RebarSubclass.ReleaseHandle();
         RebarSubclass = null;
     }
 }
Esempio n. 18
0
 public virtual void SetSite(object pUnkSite) {
     if(this.BandObjectSite != null) {
         Marshal.ReleaseComObject(this.BandObjectSite);
     }
     if(this.Explorer != null) {
         Marshal.ReleaseComObject(this.Explorer);
         this.Explorer = null;
     }
     this.BandObjectSite = pUnkSite as IInputObjectSite;
     if(this.BandObjectSite != null) {
         Guid guid = ExplorerGUIDs.IID_IWebBrowserApp;
         Guid riid = ExplorerGUIDs.IID_IUnknown;
         try {
             object obj2;
             ((_IServiceProvider)this.BandObjectSite).QueryService(ref guid, ref riid, out obj2);
             this.Explorer = (WebBrowserClass)Marshal.CreateWrapperOfType(obj2 as IWebBrowser, typeof(WebBrowserClass));
             this.OnExplorerAttached();
         }
         catch(COMException) {
         }
     }
     try {
         BandObjectLib.IOleWindow window = pUnkSite as BandObjectLib.IOleWindow;
         if(window != null) {
             window.GetWindow(out this.ReBarHandle);
         }
     }
     catch {
     }
 }