internal void OnUIDeactivate(ActiveXBase <TActiveXClass, TActiveXInterface> site)
 {
     this.siteUIActive = null;
     site.RemoveSelectionHandler();
     site.SetSelectionStyle(ActiveXHelper.SelectionStyle.Selected);
     site.SetEditMode(ActiveXHelper.ActiveXEditMode.None);
 }
            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);
                    }
                }
            }