Ejemplo n.º 1
0
        /// <summary>
        /// win10
        /// </summary>
        /// <param name="HWnd"></param>
        /// <param name="hasFrame"></param>
        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;

            NativeMethodsUltimate.SetWindowCompositionAttribute(HWnd, ref data);

            Marshal.FreeHGlobal(accentPtr);
        }