Exemple #1
0
        /// <summary>
        /// Applies the aeroglass effect to the whole window, if possible.
        /// Returns whether the effect is supported in the current environment and was applied successfully.
        /// </summary>
        public static bool Glassify(IntPtr handle, bool enable)
        {
            if (handle == IntPtr.Zero)
            {
                throw new ArgumentNullException("handle");
            }

            // Is the glass effect available?
            if (!((Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version >= new Version(6, 0)) && (Win32Declarations.DwmIsCompositionEnabled())))
            {
                return(false);
            }

            // Try glassifying the window
            return(Win32Declarations.DwmExtendFrameIntoClientArea(handle, (enable ? Win32Declarations.MARGINS.WholeSurface : Win32Declarations.MARGINS.Null)) >= 0);
        }