Example #1
0
		/// <summary>
		/// 在窗口背后启用模糊效果
		/// </summary>
		/// <param name="window">目标窗口</param>
		/// <returns>成功与否</returns>
		public static bool EnableBlurBehindWindow(Window window)
		{
			if (!AeroGlassCompositionEnabled)
				return false;

			IntPtr hwnd = new WindowInteropHelper(window).Handle;
			if (hwnd == IntPtr.Zero)
				throw new InvalidOperationException("在启用Aero效果前窗口必须已显示");

			//创建DWM_BLURBEHIND结构
			DWM_BLURBEHIND bb = new DWM_BLURBEHIND();
			bb.dwFlags = DWM_BLURBEHIND.DWM_BB_ENABLE | DWM_BLURBEHIND.DWM_BB_BLURREGION;
			bb.fEnable = true;
			bb.hRegionBlur = NativeMethods.CreateRectRgn(0, 0, (int)window.ActualWidth, (int)window.ActualHeight);

			try
			{
				NativeMethods.DwmEnableBlurBehindWindow(hwnd, ref bb);
			}
			catch { }
			//回收句柄
			NativeMethods.DeleteObject(bb.hRegionBlur);
			
			return true;
		}
Example #2
0
		internal static extern void DwmEnableBlurBehindWindow(IntPtr hWnd, ref DWM_BLURBEHIND pBlurBehind);