예제 #1
0
        /// <summary>
        /// Resets the AeroGlass exclusion area.
        /// </summary>
        protected void ResetAeroGlass()
        {
            var margins = new Margins(true);

            try
            {
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(WindowHandle, ref margins);
            }
            catch (DllNotFoundException) { }
        }
예제 #2
0
        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            switch (msg)
            {
            case DwmMessages.WmDwmCompositionChanged:
            case DwmMessages.WmDwmNcRenderingChanged:
                AeroGlassCompositionChanged.Invoke(this, new AeroGlassCompositionChangedEventArgs(AeroGlassCompositionEnabled));
                handled = true;
                break;

            case DwmMessages.WmNcCalcSize:
                handled = DrawOnTitleBar;
                break;

            case DwmMessages.WmNcHitTest:
                if (!(handled = DrawOnTitleBar))
                {
                    break;
                }
                var result = IntPtr.Zero;
                handled = DesktopWindowManagerNativeMethods.DwmDefWindowProc(hwnd, msg, wParam, lParam, ref result) != 0;
                if (handled)
                {
                    return(result);
                }
                if (WindowState == WindowState.Maximized)
                {
                    return(new IntPtr(1));                                          // no necessary to change the size when maximized
                }
                var       mouse = new Point(lParam.ToInt32() & 0xFFFF, lParam.ToInt32() >> 16);
                const int border = 6;
                double    right = Left + ActualWidth, bottom = Top + ActualHeight;
                return(new IntPtr(
                           mouse.X - Left <= border
                                ? mouse.Y - Top <= border ? 13 : bottom - mouse.Y <= border ? 16 : 10   // top bottom left
                            : right - mouse.X <= border
                                ? mouse.Y - Top <= border ? 14 : bottom - mouse.Y <= border ? 17 : 11   // top bottom right
                                : mouse.Y - Top <= border ? 12 : bottom - mouse.Y <= border ? 15 : 1)); // top bottom normal

            default:
                handled = false;
                break;
            }
            return(IntPtr.Zero);
        }