internal void ActivateInGroupLimits(HwndAdorner adorner) { if( !m_owned ) return; var current = m_ownerSource.Handle; // getting the hwnd above the owner (in win32, the prev hwnd is the one visually above) var prev = Win32.GetWindow(current, Win32.GW_HWNDPREV); // searching up for the first non-sibling hwnd while (IsSibling(prev)) { current = prev; prev = Win32.GetWindow(current, Win32.GW_HWNDPREV); } if (prev == IntPtr.Zero) // the owner or one of the siblings is the Top-most window { // setting the Top-most under the activated adorner Win32.SetWindowPos(current, adorner.Handle, 0, 0, 0, 0, SET_ONLY_ZORDER); } else { // setting the activated adorner under the first non-sibling hwnd Win32.SetWindowPos(adorner.Handle, prev, 0, 0, 0, 0, SET_ONLY_ZORDER); } }
internal void ActivateInGroupLimits(HwndAdorner adorner) { if (!m_owned) { return; } var current = m_ownerSource.Handle; // getting the hwnd above the owner (in win32, the prev hwnd is the one visually above) var prev = Win32.GetWindow(current, Win32.GW_HWNDPREV); // searching up for the first non-sibling hwnd while (IsSibling(prev)) { current = prev; prev = Win32.GetWindow(current, Win32.GW_HWNDPREV); } if (prev == IntPtr.Zero) // the owner or one of the siblings is the Top-most window { // setting the Top-most under the activated adorner Win32.SetWindowPos(current, adorner.Handle, 0, 0, 0, 0, SET_ONLY_ZORDER); } else { // setting the activated adorner under the first non-sibling hwnd Win32.SetWindowPos(adorner.Handle, prev, 0, 0, 0, 0, SET_ONLY_ZORDER); } }
internal bool AddAdorner(HwndAdorner adorner) { if (!Activated) { Activate(); } lock (m_adornersInGroup) { if (!m_adornersInGroup.Contains(adorner)) { m_adornersInGroup.Add(adorner); } } if (m_owned) { SetOwnership(adorner); ActivateInGroupLimits(adorner); adorner.InvalidateAppearance(); var root = (UIElement)m_ownerSource.RootVisual; adorner.UpdateOwnerPosition(GetRectFromRoot(root)); } return(true); }
private static void OnAdornmentAttached(DependencyObject d, DependencyPropertyChangedEventArgs args) { var element = d as FrameworkElement; if(element == null) return; UIElement adornment = (UIElement) args.NewValue; var adorner = GetHwndAdorner(element); if (adornment != null) { if (adorner == null) { SetHwndAdorner(element, adorner = new HwndAdorner(element)); } adorner.Adornment = adornment; } else { if (adorner != null) { adorner.Dispose(); SetHwndAdorner(element, null); } } }
public HwndAdornerElement() { m_hwndAdorner = new HwndAdorner(this); // This helps dependency property inheritance and resource search cross the visual tree boundary // (between the tree containing this object and the one containing the adorner root) AddLogicalChild(m_hwndAdorner.Root); }
internal bool RemoveAdorner(HwndAdorner adorner) { var res = m_adornersInGroup.Remove(adorner); if (m_owned) { RemoveOwnership(adorner); adorner.InvalidateAppearance(); } if (!HasAdorners) { Deactivate(); } return(res); }
internal bool AddAdorner(HwndAdorner adorner) { if (!Activated) { Activate(); } if (!m_adornersInGroup.Contains(adorner)) { m_adornersInGroup.Add(adorner); } if (m_owned) { SetOwnership(adorner); ActivateInGroupLimits(adorner); adorner.InvalidateAppearance(); var root = (UIElement) m_ownerSource.RootVisual; adorner.UpdateOwnerPosition(GetRectFromRoot(root)); } return true; }
public HwndHostPresenter() { m_hwndAdorner = new HwndAdorner(this); AddLogicalChild(m_hwndAdorner.Root); }
private static void RemoveOwnership(HwndAdorner adorner) { Win32.SetWindowLong(adorner.Handle, Win32.GWL_HWNDPARENT, IntPtr.Zero); }
private void SetOwnership(HwndAdorner adorner) { Win32.SetWindowLong(adorner.Handle, Win32.GWL_HWNDPARENT, m_ownerSource.Handle); }
internal bool RemoveAdorner(HwndAdorner adorner) { var res = m_adornersInGroup.Remove(adorner); if (m_owned) { RemoveOwnership(adorner); adorner.InvalidateAppearance(); } if (!HasAdorners) { Deactivate(); } return res; }
private static void SetHwndAdorner(DependencyObject element, HwndAdorner value) { element.SetValue(HwndAdornerProperty, value); }