Disable Acrylic while Moving or Resizing Window
This commit is contained in:
1 parent
40c9d45278
commit
63aa73f427
1 file changed
+46
-13
@@ -1,4 +1,6 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows.Interop;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
using HandyControl.Tools;
|
using HandyControl.Tools;
|
||||||
using HandyControl.Tools.Helper;
|
using HandyControl.Tools.Helper;
|
||||||
@@ -8,13 +10,41 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
public class BlurWindow : Window
|
public class BlurWindow : Window
|
||||||
{
|
{
|
||||||
|
private static readonly int WM_EXITSIZEMOVE = 0x0232;
|
||||||
|
private static readonly int WM_ENTERSIZEMOVE = 0x0231;
|
||||||
|
|
||||||
|
public BlurWindow()
|
||||||
|
{
|
||||||
|
var versionInfo = SystemHelper.GetSystemVersionInfo();
|
||||||
|
|
||||||
|
if (versionInfo >= SystemVersionInfo.Windows10_1903)
|
||||||
|
{
|
||||||
|
var source = HwndSource.FromHwnd(WindowHelper.GetHandle(this));
|
||||||
|
source.AddHook(WndProc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||||
|
{
|
||||||
|
if (msg == WM_ENTERSIZEMOVE)
|
||||||
|
{
|
||||||
|
EnableBlur(this, false);
|
||||||
|
}
|
||||||
|
else if (msg == WM_EXITSIZEMOVE)
|
||||||
|
{
|
||||||
|
EnableBlur(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return IntPtr.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnApplyTemplate()
|
public override void OnApplyTemplate()
|
||||||
{
|
{
|
||||||
base.OnApplyTemplate();
|
base.OnApplyTemplate();
|
||||||
EnableBlur(this);
|
EnableBlur(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void EnableBlur(Window window)
|
internal static void EnableBlur(Window window, bool isEnabled = true)
|
||||||
{
|
{
|
||||||
var versionInfo = SystemHelper.GetSystemVersionInfo();
|
var versionInfo = SystemHelper.GetSystemVersionInfo();
|
||||||
|
|
||||||
@@ -23,21 +53,24 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
accentPolicy.AccentFlags = 2;
|
accentPolicy.AccentFlags = 2;
|
||||||
|
|
||||||
if (versionInfo >= SystemVersionInfo.Windows10_1903)
|
if (isEnabled)
|
||||||
{
|
{
|
||||||
accentPolicy.AccentState = InteropValues.ACCENTSTATE.ACCENT_ENABLE_BLURBEHIND;
|
if (versionInfo >= SystemVersionInfo.Windows10_1809)
|
||||||
}
|
{
|
||||||
else if (versionInfo >= SystemVersionInfo.Windows10_1809)
|
accentPolicy.AccentState = InteropValues.ACCENTSTATE.ACCENT_ENABLE_ACRYLICBLURBEHIND;
|
||||||
{
|
}
|
||||||
accentPolicy.AccentState = InteropValues.ACCENTSTATE.ACCENT_ENABLE_ACRYLICBLURBEHIND;
|
else if (versionInfo >= SystemVersionInfo.Windows10)
|
||||||
}
|
{
|
||||||
else if (versionInfo >= SystemVersionInfo.Windows10)
|
accentPolicy.AccentState = InteropValues.ACCENTSTATE.ACCENT_ENABLE_BLURBEHIND;
|
||||||
{
|
}
|
||||||
accentPolicy.AccentState = InteropValues.ACCENTSTATE.ACCENT_ENABLE_BLURBEHIND;
|
else
|
||||||
|
{
|
||||||
|
accentPolicy.AccentState = InteropValues.ACCENTSTATE.ACCENT_ENABLE_TRANSPARENTGRADIENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
accentPolicy.AccentState = InteropValues.ACCENTSTATE.ACCENT_ENABLE_TRANSPARENTGRADIENT;
|
accentPolicy.AccentState = InteropValues.ACCENTSTATE.ACCENT_ENABLE_BLURBEHIND;
|
||||||
}
|
}
|
||||||
|
|
||||||
accentPolicy.GradientColor = ResourceHelper.GetResource<uint>(ResourceToken.BlurGradientValue);
|
accentPolicy.GradientColor = ResourceHelper.GetResource<uint>(ResourceToken.BlurGradientValue);
|
||||||
|
|||||||
Reference in new issue
Block a user