Example #1
0
 internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WINCOMPATTRDATA data);
Example #2
0
 public static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WINCOMPATTRDATA data);
        private void SetBlurEffect()
        {
            Background = new SolidColorBrush(Color.FromArgb(0x90, 0xFF, 0xFF, 0xFF));
            WindowStyle = WindowStyle.None;

            var interopHelper = new WindowInteropHelper(this);

            var accentPolicy = new ACCENTPOLICY
            {
                nAccentState = 3
            };

            var accentPolicySize = Marshal.SizeOf(accentPolicy);
            var accentPolicyPtr = Marshal.AllocHGlobal(accentPolicySize);

            Marshal.StructureToPtr(accentPolicy, accentPolicyPtr, false);

            var winCompatData = new WINCOMPATTRDATA
            {
                nAttribute = 19,
                ulDataSize = accentPolicySize,
                pData = accentPolicyPtr
            };

            NativeMethods.SetWindowCompositionAttribute(interopHelper.Handle, ref winCompatData);

            Marshal.FreeHGlobal(accentPolicyPtr);
        }