/// <summary> /// ResetBlur /// Resets the blur on the Window/form /// </summary> /// <param name="windowHandle">Handle to client window/form</param> internal static void ResetBlur(IntPtr windowHandle) { // Create and populate the BlurBehind structure SafeNativeMethods.DWM_BLURBEHIND blurBehind = new SafeNativeMethods.DWM_BLURBEHIND(); blurBehind.fEnable = false; blurBehind.dwFlags = SafeNativeMethods.DwmBlurBehindDwFlags.DWM_BB_ENABLE | SafeNativeMethods.DwmBlurBehindDwFlags.DWM_BB_BLURREGION; blurBehind.hRgnBlur = IntPtr.Zero; UnsafeNativeMethods.DwmEnableBlurBehindWindow(windowHandle, ref blurBehind); }
internal static extern int DwmEnableBlurBehindWindow( IntPtr hwnd, ref SafeNativeMethods.DWM_BLURBEHIND bb);
void ActivateGlass() { PresentationSource p = PresentationSource.FromVisual(this); HwndSource s_hwndSource = p as HwndSource; if (s_hwndSource != null) { s_hwndSource.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0); handle = s_hwndSource.Handle; } SafeNativeMethods.RECT r = new SafeNativeMethods.RECT(); UnsafeNativeMethods.GetClientRect(handle, ref r); IntPtr hrgn = UnsafeNativeMethods.CreateRectRgn(0, 0, 1, 1); SafeNativeMethods.DWM_BLURBEHIND bb = new SafeNativeMethods.DWM_BLURBEHIND(); bb.dwFlags = SafeNativeMethods.DwmBlurBehindDwFlags.DWM_BB_ENABLE | SafeNativeMethods.DwmBlurBehindDwFlags.DWM_BB_BLURREGION; bb.fEnable = true; bb.hRgnBlur = hrgn; UnsafeNativeMethods.DwmEnableBlurBehindWindow(handle, ref bb); SafeNativeMethods.MARGINS mar = new SafeNativeMethods.MARGINS(); mar.cyTopHeight = 37; UnsafeNativeMethods.DwmExtendFrameIntoClientArea(handle, ref mar); //Need to make the Window size dirty. this.WindowState = WindowState.Minimized; this.WindowState = WindowState.Normal; }