예제 #1
0
파일: Graphics.cs 프로젝트: hansuky/Yuhan
        /// <summary>
        /// Start aero in the given window
        /// </summary>
        /// <param name="window">Window</param>
        /// <param name="captionHeight">Window caption height</param>
        /// <returns>Return true if aero enabled; otherwise return false</returns>
        public static bool InicializeAero(Window window, int captionHeight)
        {
            bool aeroEnabled = false;

            // XP is version 5, Vista is version 6
            if (Environment.OSVersion.Version.Major >= 6)
            {
                try
                {
                    VistaApi.DwmIsCompositionEnabled(ref aeroEnabled);

                    if (aeroEnabled)
                    {
                        IntPtr mainWindowPtr = new WindowInteropHelper(window).Handle;
                        HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
                        mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);

                        // extend glass effect
                        VistaApi.Margins margins = new VistaApi.Margins();
                        margins.Set(0, 0, captionHeight, 0);

                        // inicialize aero
                        VistaApi.DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
                    }
                }
                // glass effect is not supported
                catch (DllNotFoundException)
                {
                    aeroEnabled = false;
                }
            }

            return aeroEnabled;
        }
예제 #2
0
파일: Graphics.cs 프로젝트: tablesmit/Yuhan
        /// <summary>
        /// Start aero in the given window
        /// </summary>
        /// <param name="window">Window</param>
        /// <param name="captionHeight">Window caption height</param>
        /// <returns>Return true if aero enabled; otherwise return false</returns>
        public static bool InicializeAero(Window window, int captionHeight)
        {
            bool aeroEnabled = false;

            // XP is version 5, Vista is version 6
            if (Environment.OSVersion.Version.Major >= 6)
            {
                try
                {
                    VistaApi.DwmIsCompositionEnabled(ref aeroEnabled);

                    if (aeroEnabled)
                    {
                        IntPtr     mainWindowPtr = new WindowInteropHelper(window).Handle;
                        HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
                        mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);

                        // extend glass effect
                        VistaApi.Margins margins = new VistaApi.Margins();
                        margins.Set(0, 0, captionHeight, 0);

                        // inicialize aero
                        VistaApi.DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
                    }
                }
                // glass effect is not supported
                catch (DllNotFoundException)
                {
                    aeroEnabled = false;
                }
            }

            return(aeroEnabled);
        }