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); }
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); }
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); } } }
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); }
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); }
private UnsafeNativeMethods.IOleObject GetOleObject() { if (iOleObject == null) { Debug.Assert(instance != null, "must have the ocx"); iOleObject = (UnsafeNativeMethods.IOleObject) instance; } return iOleObject; }
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--; } }