public static bool EnableGlass(ref IntPtr handle, IntPtr rgn) //Try to enable Aero Glass. If success return true { Region region = new Region(); region.MakeInfinite(); //Graphics graphics = Graphics.FromHwnd(handle); BB_Struct bb = new BB_Struct(); bb.enable = true; bb.flags = BB_Flags.DWM_BB_ENABLE | BB_Flags.DWM_BB_BLURREGION; if (region != null) { bb.region = rgn; } else { bb.region = IntPtr.Zero; //Region.GetHrgn(Graphics) } /*HwndSource hwndSource = HwndSource.FromHwnd(handle); * hwndSource.CompositionTarget.BackgroundColor = System.Windows.Media.Color.FromArgb(0, 0, 0, 0);*/ if (DwmEnableBlurBehindWindow(handle, ref bb) != 0) { return(false); } else { return(true); } }
public static bool DisableGlass(ref IntPtr handle) //Try to disable Aero Glass. If success return true { Region region = new Region(); Graphics graphics = Graphics.FromHwnd(handle); BB_Struct bb = new BB_Struct(); bb.enable = false; bb.flags = BB_Flags.DWM_BB_ENABLE | BB_Flags.DWM_BB_BLURREGION; bb.region = IntPtr.Zero; //Region.GetHrgn(Graphics) if (DwmEnableBlurBehindWindow(handle, ref bb) != 0) { return(false); } else { return(true); } }
private static extern int DwmEnableBlurBehindWindow(IntPtr hWnd, ref BB_Struct BlurBehind);