Exemple #1
0
    // https://www.codeproject.com/Answers/1174965/How-can-I-make-my-form-like-windows-blurr-effect-o#answer3
    public static void enableBlur(this Form @this)
    {
        var accent = new Win32Util.AccentPolicy();

        accent.AccentState = Win32Util.AccentState.ACCENT_ENABLE_BLURBEHIND;
        var accentStructSize = Marshal.SizeOf(accent);
        var accentPtr        = Marshal.AllocHGlobal(accentStructSize);

        Marshal.StructureToPtr(accent, accentPtr, false);
        var Data = new Win32Util.WindowCompositionAttributeData();

        Data.Attribute  = Win32Util.WindowCompositionAttribute.WCA_ACCENT_POLICY;
        Data.SizeOfData = accentStructSize;
        Data.Data       = accentPtr;
        Win32Util.SetWindowCompositionAttribute(@this.Handle, ref Data);
        Marshal.FreeHGlobal(accentPtr);
    }