Пример #1
0
        /// <summary>
        /// Enables blur behind window.
        /// </summary>
        /// <param name="enable">Set to <c>true</c> to enable blur behind window. Set to <c>false</c> to disable blur behind window.</param>
        /// <returns><c>true</c> if succeeds; otherwise, <c>false</c>.</returns>
        public bool EnableBlurBehindWindow(bool enable = true)
        {
            if (!IsCompositionEnabled)
                return false;

            IntPtr hwnd = new WindowInteropHelper(Window).EnsureHandle();

            var bb = new DWM_BLURBEHIND
            {
                dwFlags = DWM_BLURBEHIND.DWM_BB_ENABLE | DWM_BLURBEHIND.DWM_BB_BLURREGION,
                fEnable = enable,
                hRegionBlur = IntPtr.Zero
            };

            try
            {
                NativeMethods.DwmEnableBlurBehindWindow(hwnd, ref bb);
                return true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                return false;
            }
            finally
            {
                NativeMethods.DeleteObject(bb.hRegionBlur);
            }
        }
Пример #2
0
 internal static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);
Пример #3
0
 internal static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);