/// <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("control"); } if (AeroGlassCompositionEnabled) { Rectangle clientScreen = this.RectangleToScreen(this.ClientRectangle); Rectangle controlRect = control.ClientRectangle; //controlRect.Inflate(-1, -1); controlRect.Y++; controlRect.Height--; Rectangle controlScreen = control.RectangleToScreen(controlRect); 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); } }
/// <summary> /// Resets the AeroGlass exclusion area. /// </summary> public void ResetAeroGlass() { if (AeroGlassCompositionEnabled && this.Handle != IntPtr.Zero) { Margins margins = new Margins(true); DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(this.Handle, ref margins); } }
public void ExcludeRectangleFromAeroGlass(Rectangle rectangle) { if (AeroGlassCompositionEnabled) { Margins margins = new Margins(); margins.LeftWidth = rectangle.X; margins.TopHeight = rectangle.Y; margins.RightWidth = ClientSize.Width - rectangle.Right; margins.BottomHeight = Height - rectangle.Bottom; // Extend the Frame into client area DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(Handle, ref margins); } }