public static bool ExtendGlassFrame(Window window , Thickness margin)
 {
     if (!DwmApi.DwmIsCompositionEnabled())
         return false;
     IntPtr hwnd = new WindowInteropHelper(window).Handle;
     if (hwnd == IntPtr.Zero)
         throw new InvalidOperationException("The Window must be shown before extending glass.");
     // Set the background to transparent from both the WPF and Win32 perspectives
     window.Background = Brushes.Transparent;
     HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
     DwmApi.MARGINS margins = new DwmApi.MARGINS((int)margin.Left , (int)margin.Top , (int)margin.Right , (int)margin.Bottom);
     DwmApi.DwmExtendFrameIntoClientArea(hwnd , margins);
     return true;
 }
Exemple #2
0
        public static bool ExtendGlassFrame(Window window, Thickness margin)
        {
            if (!DwmApi.DwmIsCompositionEnabled())
            {
                return(false);
            }
            IntPtr hwnd = new WindowInteropHelper(window).Handle;

            if (hwnd == IntPtr.Zero)
            {
                throw new InvalidOperationException("The Window must be shown before extending glass.");
            }
            // Set the background to transparent from both the WPF and Win32 perspectives
            window.Background = Brushes.Transparent;
            HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
            DwmApi.MARGINS margins = new DwmApi.MARGINS((int)margin.Left, (int)margin.Top, (int)margin.Right, (int)margin.Bottom);
            DwmApi.DwmExtendFrameIntoClientArea(hwnd, margins);
            return(true);
        }