From 2ec71c9942eaf9640caa2a65d1ae8a0d9c311ed3 Mon Sep 17 00:00:00 2001 From: Yeechan Lu Date: Wed, 26 Mar 2014 19:26:10 +0800 Subject: [PATCH] Fix issue with Layered Window --- Wox/Helper/DWMDropShadow.cs | 6 ++---- Wox/MainWindow.xaml.cs | 4 ++++ Wox/Themes/Aero Dark.xaml | 2 +- Wox/Themes/Aero Light.xaml | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Wox/Helper/DWMDropShadow.cs b/Wox/Helper/DWMDropShadow.cs index b50dff4b6..60253f8c0 100644 --- a/Wox/Helper/DWMDropShadow.cs +++ b/Wox/Helper/DWMDropShadow.cs @@ -50,10 +50,8 @@ namespace Wox.Helper { WindowInteropHelper helper = new WindowInteropHelper(window); int val = 2; - int ret1 = DwmSetWindowAttribute(helper.Handle, 2, ref val, 4); - window.Background = Brushes.Transparent; - HwndSource.FromHwnd(helper.Handle).CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0); - + int ret1 = DwmSetWindowAttribute(helper.Handle, 2, ref val, 4); + if (ret1 == 0) { Margins m = new Margins { Bottom = 0, Left = 0, Right = 0, Top = 0 }; diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 245968619..3c47eb06e 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -8,6 +8,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Forms; using System.Windows.Input; +using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Animation; using WindowsInput; @@ -97,6 +98,9 @@ namespace Wox if (UserSettingStorage.Instance.OpacityMode == OpacityMode.DWM) DwmDropShadow.DropShadowToWindow(this); + this.Background = Brushes.Transparent; + HwndSource.FromHwnd(new WindowInteropHelper(this).Handle).CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0); + WindowIntelopHelper.DisableControlBox(this); } diff --git a/Wox/Themes/Aero Dark.xaml b/Wox/Themes/Aero Dark.xaml index 5350d2fce..7d83892a1 100644 --- a/Wox/Themes/Aero Dark.xaml +++ b/Wox/Themes/Aero Dark.xaml @@ -16,7 +16,7 @@ diff --git a/Wox/Themes/Aero Light.xaml b/Wox/Themes/Aero Light.xaml index 73d7c0c3b..d65925900 100644 --- a/Wox/Themes/Aero Light.xaml +++ b/Wox/Themes/Aero Light.xaml @@ -16,7 +16,7 @@