好像这个不能开WS_SIZEBOX,不然上边一直有一块蓝条去不掉。。。
开不开Win8式粗边框也是问题,不开放到纯色上边就看不见了,开了又和原窗口大小不同了。。。
开不开Win8式粗边框也是问题,不开放到纯色上边就看不见了,开了又和原窗口大小不同了。。。
public static void EnableBlur(IntPtr HWnd, bool hasFrame = true)
{
AccentPolicy accent = new AccentPolicy();
accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
if (hasFrame)
accent.AccentFlags = 0x20 | 0x40 | 0x80 | 0x100;
int accentStructSize = Marshal.SizeOf(accent);
IntPtr accentPtr = Marshal.AllocHGlobal(accentStructSize);
Marshal.StructureToPtr(accent, accentPtr, false);
WindowCompositionAttributeData data = new WindowCompositionAttributeData();
data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY;
data.SizeOfData = accentStructSize;
data.Data = accentPtr;
WinAPI.SetWindowCompositionAttribute(HWnd, ref data);
Marshal.FreeHGlobal(accentPtr);
}
protected override CreateParams CreateParams
{
get
{
CreateParams cParms = base.CreateParams;
cParms.Style |= Constants.WS_SYSMENU;
cParms.ExStyle |= Constants.WS_EX_LAYERED;
return cParms;
}
}
public Form1()
{
InitializeComponent();
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
}
private void Form1_Load(object sender, EventArgs e)
{
(new LayeredWindowHelper(this)).BackColor = Color.FromArgb(128, Win7Style.GetThemeColor());
Win7Style.EnableBlurBehindWindow(this.Handle);
Win10Style.EnableBlur(this.Handle);
}
200字以内,仅用于支线交流,主线讨论请采用回复功能。