-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathNativeMethods.BlurBg.cs
92 lines (79 loc) · 2.44 KB
/
NativeMethods.BlurBg.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Runtime.InteropServices;
namespace VoicemeeterOsdProgram.Interop;
partial class NativeMethods
{
[StructLayout(LayoutKind.Sequential)]
internal struct WindowCompositionAttributeData
{
public WindowCompositionAttribute Attribute;
public IntPtr Data;
public int SizeOfData;
}
internal enum WindowCompositionAttribute
{
WCA_ACCENT_POLICY = 19
}
internal enum AccentState
{
ACCENT_DISABLED = 0,
ACCENT_ENABLE_GRADIENT = 1,
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
ACCENT_ENABLE_BLURBEHIND = 3,
ACCENT_ENABLE_ACRYLICBLURBEHIND = 4, // RS4 1803, MAY NOT WORK
ACCENT_ENABLE_HOSTBACKDROP = 5, // RS5 1809, MAY NOT WORK
ACCENT_INVALID_STATE = 6
}
[StructLayout(LayoutKind.Sequential)]
internal struct AccentPolicy
{
public AccentState AccentState;
public int AccentFlags;
public int GradientColor;
public int AnimationId;
}
[DllImport("user32.dll")]
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
[Flags]
internal enum DWM_BB
{
Enable = 1,
BlurRegion = 2,
TransitionMaximized = 4
}
[StructLayout(LayoutKind.Sequential)]
internal struct DWM_BLURBEHIND
{
public DWM_BB dwFlags;
public bool fEnable;
public IntPtr hRgnBlur;
public bool fTransitionOnMaximized;
public DWM_BLURBEHIND(bool enabled)
{
fEnable = enabled ? true : false;
hRgnBlur = IntPtr.Zero;
fTransitionOnMaximized = false;
dwFlags = DWM_BB.Enable;
}
public System.Drawing.Region Region
{
get { return System.Drawing.Region.FromHrgn(hRgnBlur); }
}
public bool TransitionOnMaximized
{
get { return fTransitionOnMaximized; }
set
{
fTransitionOnMaximized = value ? true : false;
dwFlags |= DWM_BB.TransitionMaximized;
}
}
public void SetRegion(System.Drawing.Graphics graphics, System.Drawing.Region region)
{
hRgnBlur = region.GetHrgn(graphics);
dwFlags |= DWM_BB.BlurRegion;
}
}
[DllImport("dwmapi.dll")]
internal static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);
}