/// <summary>
        /// Excludes a UI element from the AeroGlass frame.
        /// </summary>
        /// <param name="element">The element to exclude.</param>
        /// <remarks>Many non-WPF rendered controls (i.e., the ExplorerBrowser control) will not 
        /// render properly on top of an AeroGlass frame. </remarks>
        public void ExcludeElementFromAeroGlass(FrameworkElement element)
        {
            if (AeroGlassCompositionEnabled && element != null)
            {
                // calculate total size of window nonclient area
                var hwndSource = PresentationSource.FromVisual(this) as HwndSource;
                NativeRect windowRect;
                NativeRect clientRect;
                DesktopWindowManagerNativeMethods.GetWindowRect(hwndSource.Handle, out windowRect);
                DesktopWindowManagerNativeMethods.GetClientRect(hwndSource.Handle, out clientRect);
                var nonClientSize = new Size(
                        (double)(windowRect.Right - windowRect.Left) - (clientRect.Right - clientRect.Left),
                        (double)(windowRect.Bottom - windowRect.Top) - (clientRect.Bottom - clientRect.Top));

                // calculate size of element relative to nonclient area
                GeneralTransform transform = element.TransformToAncestor(this);
                Point topLeftFrame = transform.Transform(new Point(0, 0));
                Point bottomRightFrame = transform.Transform(new Point(
                            element.ActualWidth + nonClientSize.Width,
                            element.ActualHeight + nonClientSize.Height));

                // Create a margin structure
                var margins = new Margins();
                margins.LeftWidth = (int)topLeftFrame.X;
                margins.RightWidth = (int)(this.ActualWidth - bottomRightFrame.X);
                margins.TopHeight = (int)(topLeftFrame.Y);
                margins.BottomHeight = (int)(this.ActualHeight - bottomRightFrame.Y);

                // Extend the Frame into client area
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(windowHandle, ref margins);
            }
        }
        /// <summary>
        /// Excludes a Control from the AeroGlass frame.
        /// </summary>
        /// <param name="control">The control to exclude.</param>
        /// <remarks>Many non-WPF rendered controls (i.e., the ExplorerBrowser control) will not 
        /// render properly on top of an AeroGlass frame. </remarks>
        public void ExcludeControlFromAeroGlass(Control control)
        {
            if (control == null) { throw new ArgumentNullException(nameof(control)); }

            if (AeroGlassCompositionEnabled)
            {
                Rectangle clientScreen = this.RectangleToScreen(this.ClientRectangle);
                Rectangle controlScreen = control.RectangleToScreen(control.ClientRectangle);

                Margins margins = new Margins();
                margins.LeftWidth = controlScreen.Left - clientScreen.Left;
                margins.RightWidth = clientScreen.Right - controlScreen.Right;
                margins.TopHeight = controlScreen.Top - clientScreen.Top;
                margins.BottomHeight = clientScreen.Bottom - controlScreen.Bottom;

                // Extend the Frame into client area
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(Handle, ref margins);
            }
        }
 internal static extern int DwmExtendFrameIntoClientArea(
     IntPtr hwnd,
     ref Margins m);
 /// <summary>
 /// Resets the AeroGlass exclusion area.
 /// </summary>
 public void ResetAeroGlass()
 {
     if (this.Handle != IntPtr.Zero)
     {
         Margins margins = new Margins(true);
         DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(this.Handle, ref margins);
     }
 }
 /// <summary>
 /// Resets the AeroGlass exclusion area.
 /// </summary>
 public void ResetAeroGlass()
 {
     var margins = new Margins(true);
     DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(windowHandle, ref margins);
 }
 internal static extern int DwmExtendFrameIntoClientArea(
     IntPtr hwnd,
     ref Margins m);