private void DetachInterfacesInternal()
 {
     this.activeXOleObject              = null;
     this.activeXOleInPlaceObject       = null;
     this.activexOleInPlaceActiveObject = null;
     this.activeXOleControl             = null;
     this.DetachInterfaces();
 }
 private void AttachInterfacesInternal()
 {
     this.activeXOleObject              = (UnsafeNativeMethods.IOleObject) this.ActiveXInstance;
     this.activeXOleInPlaceObject       = (UnsafeNativeMethods.IOleInPlaceObject) this.ActiveXInstance;
     this.activexOleInPlaceActiveObject = (UnsafeNativeMethods.IOleInPlaceActiveObject) this.ActiveXInstance;
     this.activeXOleControl             = (UnsafeNativeMethods.IOleControl) this.ActiveXInstance;
     this.AttachInterfaces(this.ActiveXInstance);
 }
Пример #3
0
 public int ShowUI(
     int dwID,
     UnsafeNativeMethods.IOleInPlaceActiveObject activeObject,
     NativeMethods.IOleCommandTarget commandTarget,
     UnsafeNativeMethods.IOleInPlaceFrame frame,
     UnsafeNativeMethods.IOleInPlaceUIWindow doc)
 {
     // default means we don't have any UI, and control should show its UI
     return(NativeMethods.SRESULTS.S_FALSE);
 }
Пример #4
0
        int UnsafeNativeMethods.IOleInPlaceFrame.SetActiveObject(UnsafeNativeMethods.IOleInPlaceActiveObject pActiveObject, string pszObjName)
        {
            if (pActiveObject == null)
            {
                if (ctlInEditMode != null)
                {
                    ctlInEditMode.SetEditMode(WebBrowserHelper.AXEditMode.None);
                    ctlInEditMode = null;
                }
                return(NativeMethods.S_OK);
            }
            WebBrowserBase ctl = null;

            UnsafeNativeMethods.IOleObject oleObject = pActiveObject as UnsafeNativeMethods.IOleObject;
            if (oleObject != null)
            {
                UnsafeNativeMethods.IOleClientSite clientSite = null;
                try {
                    clientSite = oleObject.GetClientSite();
                    WebBrowserSiteBase webBrowserSiteBase = clientSite as WebBrowserSiteBase;
                    if (webBrowserSiteBase != null)
                    {
                        ctl = webBrowserSiteBase.GetAXHost();
                    }
                }
                catch (COMException t) {
                    Debug.Fail(t.ToString());
                }
                if (ctlInEditMode != null)
                {
                    Debug.Fail("control " + ctlInEditMode.ToString() + " did not reset its edit mode to null");
                    ctlInEditMode.SetSelectionStyle(WebBrowserHelper.SelectionStyle.Selected);
                    ctlInEditMode.SetEditMode(WebBrowserHelper.AXEditMode.None);
                }

                if (ctl == null)
                {
                    ctlInEditMode = null;
                }
                else
                {
                    if (!ctl.IsUserMode)
                    {
                        ctlInEditMode = ctl;
                        ctl.SetEditMode(WebBrowserHelper.AXEditMode.Object);
                        ctl.AddSelectionHandler();
                        ctl.SetSelectionStyle(WebBrowserHelper.SelectionStyle.Active);
                    }
                }
            }

            return(NativeMethods.S_OK);
        }
        int UnsafeNativeMethods.IOleInPlaceFrame.SetActiveObject(UnsafeNativeMethods.IOleInPlaceActiveObject pActiveObject, string pszObjName)
        {
            if (pActiveObject == null)
            {
                if (this.ctlInEditMode != null)
                {
                    this.ctlInEditMode.SetEditMode(WebBrowserHelper.AXEditMode.None);
                    this.ctlInEditMode = null;
                }
                return(0);
            }
            WebBrowserBase aXHost = null;

            UnsafeNativeMethods.IOleObject obj2 = pActiveObject as UnsafeNativeMethods.IOleObject;
            if (obj2 != null)
            {
                try
                {
                    WebBrowserSiteBase clientSite = obj2.GetClientSite() as WebBrowserSiteBase;
                    if (clientSite != null)
                    {
                        aXHost = clientSite.GetAXHost();
                    }
                }
                catch (COMException)
                {
                }
                if (this.ctlInEditMode != null)
                {
                    this.ctlInEditMode.SetSelectionStyle(WebBrowserHelper.SelectionStyle.Selected);
                    this.ctlInEditMode.SetEditMode(WebBrowserHelper.AXEditMode.None);
                }
                if (aXHost == null)
                {
                    this.ctlInEditMode = null;
                }
                else if (!aXHost.IsUserMode)
                {
                    this.ctlInEditMode = aXHost;
                    aXHost.SetEditMode(WebBrowserHelper.AXEditMode.Object);
                    aXHost.AddSelectionHandler();
                    aXHost.SetSelectionStyle(WebBrowserHelper.SelectionStyle.Active);
                }
            }
            return(0);
        }
Пример #6
0
        int UnsafeNativeMethods.IOleInPlaceFrame.SetActiveObject(UnsafeNativeMethods.IOleInPlaceActiveObject pActiveObject, string pszObjName)
        {
            //Microsoft has code to remove selection handler around the active object
            //and add it around the new one
            //
            //Since we don't have anything like that in Avalon, we do nothing
            //
            //For future reference, added skeletal code on how to get to the internal hosting
            //objects incase they are needed here.


            /*
             * ActiveXHost host = null;
             *
             * if (pActiveObject is UnsafeNativeMethods.IOleObject)
             * {
             *  UnsafeNativeMethods.IOleObject oleObject = (UnsafeNativeMethods.IOleObject)pActiveObject;
             *  UnsafeNativeMethods.IOleClientSite clientSite = null;
             *
             *  try
             *  {
             *      clientSite = oleObject.GetClientSite();
             *      if ((clientSite as ActiveXSite) != null)
             *      {
             *          ctl = ((ActiveXSite)(clientSite)).GetActiveXHost();
             *      }
             *  }
             *  catch (COMException t)
             *  {
             *      Debug.Fail(t.ToString());
             *  }
             * }
             */

            return(NativeMethods.S_OK);
        }
Пример #7
0
 int UnsafeNativeMethods.IDocHostUIHandler.ShowUI(int dwID, UnsafeNativeMethods.IOleInPlaceActiveObject activeObject,
                                                  NativeMethods.IOleCommandTarget commandTarget, UnsafeNativeMethods.IOleInPlaceFrame frame,
                                                  UnsafeNativeMethods.IOleInPlaceUIWindow doc)
 {
     return(NativeMethods.E_NOTIMPL);
 }
 private void DetachInterfacesInternal() {
     this.axOleObject = null;
     this.axOleInPlaceObject = null;
     this.axOleInPlaceActiveObject = null;
     this.axOleControl = null;
     //
     // Lets give the inheriting classes a chance to release
     // their cached interfaces of the ActiveX object.
     DetachInterfaces();
 }
 private void AttachInterfacesInternal() {
     Debug.Assert(activeXInstance != null, "The native control is null");
     this.axOleObject = (UnsafeNativeMethods.IOleObject)activeXInstance;
     this.axOleInPlaceObject = (UnsafeNativeMethods.IOleInPlaceObject)activeXInstance;
     this.axOleInPlaceActiveObject = (UnsafeNativeMethods.IOleInPlaceActiveObject)activeXInstance;
     this.axOleControl = (UnsafeNativeMethods.IOleControl)activeXInstance;
     //
     // Lets give the inheriting classes a chance to cast
     // the ActiveX object to the appropriate interfaces.
     AttachInterfaces(activeXInstance);
 }
Пример #10
0
        private UnsafeNativeMethods.IOleInPlaceActiveObject GetInPlaceActiveObject() {
            // if our AxContainer was set an external active object then use it.
            if(iOleInPlaceActiveObjectExternal != null) {
                return iOleInPlaceActiveObjectExternal;
            }

            // otherwise use our instance.
            if (iOleInPlaceActiveObject == null) {
                Debug.Assert(instance != null, "must have the ocx");
                try {
                    iOleInPlaceActiveObject = (UnsafeNativeMethods.IOleInPlaceActiveObject)instance;
                }
                catch (InvalidCastException e) {
                    Debug.Fail("Invalid cast in GetInPlaceActiveObject: " + e.ToString());
                }
            }
            return iOleInPlaceActiveObject;
        }
Пример #11
0
        private void ReleaseAxControl() {
            // This line is like a bit of magic...
            // sometimes, we crash with it on,
            // sometimes, with it off...
            // Lately, I have decided to leave it on...
            // (oh, yes, and the crashes seemed to disappear...)
            //cpr: ComLib.Release(instance);

            this.NoComponentChangeEvents++;

            ContainerControl f = ContainingControl;
            if (f != null) {
                f.VisibleChanged -= this.onContainerVisibleChanged;
            }

            try {
                if (instance != null) {
                    Marshal.FinalReleaseComObject(instance);
                    instance = null;                
                    iOleInPlaceObject = null;
                    iOleObject = null;
                    iOleControl = null;
                    iOleInPlaceActiveObject = null;
                    iOleInPlaceActiveObjectExternal = null;
                    iPerPropertyBrowsing = null;
                    iCategorizeProperties = null;
                    iPersistStream = null;
                    iPersistStreamInit = null;
                    iPersistStorage = null;
                }
                
                axState[checkedIppb] = false;
                axState[checkedCP] = false;
                axState[disposed] = true;

                freezeCount = 0;
                axState[sinkAttached] = false;
                wndprocAddr = IntPtr.Zero;

                SetOcState(OC_PASSIVE);
            }
            finally {
                this.NoComponentChangeEvents--;
            }
        }
            void UnsafeNativeMethods.IOleInPlaceFrame /*IOleInPlaceUIWindow*/.SetActiveObject(UnsafeNativeMethods.IOleInPlaceActiveObject pActiveObject, string pszObjName)
            {
                if (pActiveObject == null)
                {
                    if (this.controlInEditMode != null)
                    {
                        this.controlInEditMode.SetEditMode(ActiveXHelper.ActiveXEditMode.None);
                        this.controlInEditMode = null;
                    }
                    return;
                }

                ActiveXBase <TActiveXClass, TActiveXInterface> activeXBase = null;

                UnsafeNativeMethods.IOleObject oleObject = pActiveObject as UnsafeNativeMethods.IOleObject;
                if (oleObject != null)
                {
                    UnsafeNativeMethods.IOleClientSite oleClientSite = null;
                    try
                    {
                        oleClientSite = oleObject.GetClientSite();
                        ActiveXSiteBase activeXSiteBase = oleClientSite as ActiveXSiteBase;
                        if (activeXSiteBase != null)
                        {
                            activeXBase = activeXSiteBase.Host;
                        }
                    }
                    catch (COMException)
                    {
                    }

                    if (this.controlInEditMode != null)
                    {
                        this.controlInEditMode.SetSelectionStyle(ActiveXHelper.SelectionStyle.Selected);
                        this.controlInEditMode.SetEditMode(ActiveXHelper.ActiveXEditMode.None);
                    }

                    if (activeXBase == null)
                    {
                        this.controlInEditMode = null;
                    }
                    else if (!activeXBase.IsUserMode)
                    {
                        this.controlInEditMode = activeXBase;
                        activeXBase.SetEditMode(ActiveXHelper.ActiveXEditMode.Object);
                        activeXBase.AddSelectionHandler();
                        activeXBase.SetSelectionStyle(ActiveXHelper.SelectionStyle.Active);
                    }
                }
            }
Пример #13
0
 int UnsafeNativeMethods.IOleInPlaceFrame.SetActiveObject(UnsafeNativeMethods.IOleInPlaceActiveObject pActiveObject, string pszObjName)
 {
     return(0);
 }