Пример #1
0
 /// <summary>
 /// Resets the AeroGlass exclusion area.
 /// </summary>
 public void ResetAreoGlass( )
 {
     if( this.Handle != IntPtr.Zero )
     {
         MARGINS margins = new MARGINS( true );
         DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea( this.Handle, ref margins );
     }
 }
Пример #2
0
        /// <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( AeroGlassCompositionEnabled )
            {
                Rectangle clientScreen = this.RectangleToScreen( this.ClientRectangle );
                Rectangle controlScreen = control.RectangleToScreen( control.ClientRectangle );

                MARGINS margins = new MARGINS( );
                margins.cxLeftWidth = controlScreen.Left - clientScreen.Left;
                margins.cxRightWidth = clientScreen.Right - controlScreen.Right;
                margins.cyTopHeight = controlScreen.Top - clientScreen.Top;
                margins.cyBottomHeight = clientScreen.Bottom - controlScreen.Bottom;

                // Extend the Frame into client area
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea( Handle, ref margins );
            }
        }
Пример #3
0
        /// <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 )
            {
                // calculate total size of window nonclient area
                HwndSource hwndSource = PresentationSource.FromVisual( this ) as HwndSource;
                CoreNativeMethods.RECT windowRect = new CoreNativeMethods.RECT( );
                CoreNativeMethods.RECT clientRect = new CoreNativeMethods.RECT( );
                DesktopWindowManagerNativeMethods.GetWindowRect( hwndSource.Handle, ref windowRect );
                DesktopWindowManagerNativeMethods.GetClientRect( hwndSource.Handle, ref clientRect );
                Size nonClientSize =
                    new Size(
                        (double)(windowRect.right - windowRect.left) - (double)(clientRect.right - clientRect.left),
                        (double)(windowRect.bottom - windowRect.top) - (double)(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
                MARGINS margins = new MARGINS( );
                margins.cxLeftWidth = (int)topLeftFrame.X;
                margins.cxRightWidth = (int)(this.ActualWidth - bottomRightFrame.X);
                margins.cyTopHeight = (int)(topLeftFrame.Y);
                margins.cyBottomHeight = (int)(this.ActualHeight - bottomRightFrame.Y);

                // Extend the Frame into client area
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea( windowHandle, ref margins );
            }
        }
 internal static extern int DwmExtendFrameIntoClientArea(
     IntPtr hwnd,
     ref MARGINS m);
 internal static extern int DwmExtendFrameIntoClientArea(
     IntPtr hwnd,
     ref MARGINS m);