Ejemplo n.º 1
0
        /// <summary>
        /// Extends the glass frame.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <param name="margin">The margin.</param>
        /// <returns></returns>
        public static bool ExtendGlassFrame(System.Windows.Window window, Thickness margin)
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6 && DwmIsCompositionEnabled())
            {
                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;

                MARGINS margins = new MARGINS(margin);
                DwmExtendFrameIntoClientArea(hwnd, ref margins);
                return true;
            } else return false;

        }
Ejemplo n.º 2
0
 static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS margins);