internal void OnUIDeactivate(WebBrowserBase site) { this.siteUIActive = null; site.RemoveSelectionHandler(); site.SetSelectionStyle(WebBrowserHelper.SelectionStyle.Selected); site.SetEditMode(WebBrowserHelper.AXEditMode.None); }
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); }
internal void OnUIDeactivate(WebBrowserBase site) { #if DEBUG if (siteUIActive != null) { Debug.Assert(siteUIActive == site, "deactivating when not active..."); } #endif // DEBUG siteUIActive = null; site.RemoveSelectionHandler(); site.SetSelectionStyle(WebBrowserHelper.SelectionStyle.Selected); site.SetEditMode(WebBrowserHelper.AXEditMode.None); }
HRESULT Ole32.IOleInPlaceFrame.SetActiveObject(Ole32.IOleInPlaceActiveObject pActiveObject, string pszObjName) { if (pActiveObject is null) { if (ctlInEditMode is not null) { ctlInEditMode.SetEditMode(WebBrowserHelper.AXEditMode.None); ctlInEditMode = null; } return(HRESULT.S_OK); } WebBrowserBase ctl = null; if (pActiveObject is Ole32.IOleObject oleObject) { oleObject.GetClientSite(out Ole32.IOleClientSite clientSite); if (clientSite is WebBrowserSiteBase webBrowserSiteBase) { ctl = webBrowserSiteBase.Host; } if (ctlInEditMode is not 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 is null) { ctlInEditMode = null; } else { if (!ctl.IsUserMode) { ctlInEditMode = ctl; ctl.SetEditMode(WebBrowserHelper.AXEditMode.Object); ctl.AddSelectionHandler(); ctl.SetSelectionStyle(WebBrowserHelper.SelectionStyle.Active); } } } return(HRESULT.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); }