/// <summary>
        /// Initialize Dwm Composition parameters
        /// </summary>
        public void Init()
        {
            bool dwmEnabled;

            DwmApi.DwmIsCompositionEnabled(out dwmEnabled);

            IsDwmCompositionEnabled = dwmEnabled;

            if (dwmEnabled)
            {
                uint color;
                bool opaqueBlend;
                DwmApi.DwmGetColorizationColor(out color, out opaqueBlend);

                DwmColorizationColor = Color.FromArgb((int)color);
                if (DwmColorizationColor.A < 100)
                {
                    DwmColorizationColor = Color.FromArgb(100, DwmColorizationColor);
                }
            }

            _bbParams          = new DwmApi.DWM_BLURBEHIND();
            _bbParams.dwFlags  = DwmApi.DwmFlags.DWM_BB_ENABLE;
            _bbParams.fEnable  = true;
            _bbParams.hRgnBlur = IntPtr.Zero;
        }
示例#2
0
        private void ResetDwmBlurBehind()
        {
            OperatingSystem os = Environment.OSVersion;

            if (enableGlass)
            {
                DwmApi.DWM_BLURBEHIND bbhOff = new DwmApi.DWM_BLURBEHIND();
                bbhOff.dwFlags     = DwmApi.DWM_BLURBEHIND.DWM_BB_ENABLE | DwmApi.DWM_BLURBEHIND.DWM_BB_BLURREGION;
                bbhOff.fEnable     = false;
                bbhOff.hRegionBlur = IntPtr.Zero;
                DwmApi.DwmEnableBlurBehindWindow(this.Handle, bbhOff);
            }
        }
示例#3
0
        public void ControlHostForm()
        {
            if (HostForm != null)
            {
                int lWinBorder = 2 * libUser32.GetSystemMetrics(libUser32.SM_CXSIZEFRAME);

                if (Glass)
                {
                    DwmApi.DwmEnableComposition(true);
                    DwmApi.DWM_BLURBEHIND BlurBehind = new DwmApi.DWM_BLURBEHIND();
                    BlurBehind.dwFlags                = DwmApi.DWM_BLURBEHIND.DWM_BB_ENABLE;
                    BlurBehind.fEnable                = true;
                    BlurBehind.hRegionBlur            = IntPtr.Zero;
                    BlurBehind.fTransitionOnMaximized = false;

                    DwmApi.SetRenderingPolicy(HostForm.Handle, DwmApi.TDwmNCRenderingPolicy.Enabled);
                    DwmApi.DwmExtendFrameIntoClientArea(
                        HostForm.Handle,
                        new DwmApi.MARGINS(0, this.Height, 0, 0)
                        );

                    HostForm.ControlBox = true;
                }
                else
                {
                    HostForm.FormBorderStyle = FormBorderStyle.None;
                    HostForm.MaximizeBox     = true;
                    HostForm.MinimizeBox     = true;
                    HostForm.ControlBox      = true;
                }

                libUser32.SetWindowLong(HostForm.Handle, libUser32.GWL_STYLE, libUser32.MY_SIZEABLEBOX);
                DwmApi.ExtendFrame(HostForm.Handle);

                FormMenu = new ApplicationMenu(HostForm);
                FormMenu.AppendItem("Restore");
                FormMenu.AppendItem("Minimize");
                FormMenu.AppendItem("Maximize");
                FormMenu.AppendItem("-");
                FormMenu.AppendItem("Close");

                HostForm.MaximumSize = new Size(
                    lWinBorder + Screen.PrimaryScreen.WorkingArea.Width,
                    lWinBorder + Screen.PrimaryScreen.WorkingArea.Height
                    );
            }

            HostFormControlled = true;
        }
示例#4
0
        /// <summary>
        /// Removes the aero glass composition for this form depending on the form border style that the form had the last time the aero glass composition was enabled for it.
        /// No checks and validation are made, so use it carefully.
        /// </summary>
        /// <returns>
        /// If it succeeded, it returns 0 (DwmApi.HRESULT.S_OK), otherwise it returns the windows error code.
        /// </returns>
        protected DwmApi.HRESULT RemoveAeroGlassCompositionCore()
        {
            DwmApi.HRESULT hResult;

            if (this.FormBorderStylePrevAeroGlassCompositionEnable.Value == FormBorderStyle.None)
            {
                DwmApi.DWM_BLURBEHIND dwm_blurBehind;

                dwm_blurBehind = new DwmApi.DWM_BLURBEHIND(false);
                hResult        = this.DwmEnableBlurBehindWindow(ref dwm_blurBehind);
            }
            else
            {
                DwmApi.MARGINS margins;

                margins = new DwmApi.MARGINS();
                hResult = this.DwmExtendFrameIntoClientArea(ref margins);
            }
            return(hResult);
        }
示例#5
0
文件: GlassAb.cs 项目: fenriv/NetOpen
 private void ResetDwmBlurBehind()
 {
     if (DwmApi.DwmIsCompositionEnabled())
     {
         DwmApi.DWM_BLURBEHIND bbhOff = new DwmApi.DWM_BLURBEHIND();
         bbhOff.dwFlags = DwmApi.DWM_BLURBEHIND.DWM_BB_ENABLE | DwmApi.DWM_BLURBEHIND.DWM_BB_BLURREGION;
         bbhOff.fEnable = false;
         bbhOff.hRegionBlur = IntPtr.Zero;
         DwmApi.DwmEnableBlurBehindWindow(this.Handle, bbhOff);
     }
 }
示例#6
0
 /// <summary>
 /// Applies the aero glass composition using the 'BlurBehind' method (see https://msdn.microsoft.com/en-us/library/windows/desktop/aa969508%28v=vs.85%29.aspx).
 /// No checks and validation are made, so use it carefully.
 /// </summary>
 /// <param name="pBlurBehind">
 /// A 'DwmApi.DWM_BLURBEHIND' structure that provides blur behind data
 /// </param>
 /// <returns>
 /// If it succeeded, it returns 0 (DwmApi.HRESULT.S_OK), otherwise it returns the windows error code.
 /// </returns>
 protected DwmApi.HRESULT DwmEnableBlurBehindWindow([In] ref DwmApi.DWM_BLURBEHIND pBlurBehind)
 {
     return(DwmApi.DwmEnableBlurBehindWindow(this.Handle, ref pBlurBehind));
 }
示例#7
0
        public void ControlHostForm()
        {
            if (HostForm != null)
            {
                int lWinBorder = 2 * libUser32.GetSystemMetrics(libUser32.SM_CXSIZEFRAME);

                if (Glass)
                {
                    DwmApi.DwmEnableComposition(true);
                    DwmApi.DWM_BLURBEHIND BlurBehind = new DwmApi.DWM_BLURBEHIND();
                    BlurBehind.dwFlags = DwmApi.DWM_BLURBEHIND.DWM_BB_ENABLE;
                    BlurBehind.fEnable = true;
                    BlurBehind.hRegionBlur = IntPtr.Zero;
                    BlurBehind.fTransitionOnMaximized = false;

                    DwmApi.SetRenderingPolicy(HostForm.Handle, DwmApi.TDwmNCRenderingPolicy.Enabled);
                    DwmApi.DwmExtendFrameIntoClientArea(
                                HostForm.Handle,
                                new DwmApi.MARGINS(0, this.Height, 0, 0)
                            );

                    HostForm.ControlBox = true;

                }
                else
                {
                    HostForm.FormBorderStyle = FormBorderStyle.None;
                    HostForm.MaximizeBox = true;
                    HostForm.MinimizeBox = true;
                    HostForm.ControlBox = true;
                }

                libUser32.SetWindowLong(HostForm.Handle, libUser32.GWL_STYLE, libUser32.MY_SIZEABLEBOX);
                DwmApi.ExtendFrame(HostForm.Handle);

                FormMenu = new ApplicationMenu(HostForm);
                FormMenu.AppendItem("Restore");
                FormMenu.AppendItem("Minimize");
                FormMenu.AppendItem("Maximize");
                FormMenu.AppendItem("-");
                FormMenu.AppendItem("Close");

                HostForm.MaximumSize = new Size(
                            lWinBorder + Screen.PrimaryScreen.WorkingArea.Width,
                            lWinBorder + Screen.PrimaryScreen.WorkingArea.Height
                        );
            }

            HostFormControlled = true;
        }