示例#1
0
        public static bool ExtendGlassFrame(Window window, Thickness margin)
        {
            if (Environment.OSVersion.Version.Major < 6)
                return false;

            IntPtr hwnd = new WindowInteropHelper(window).Handle;

            MARGINS margins = new MARGINS((int)margin.Left, (int)margin.Right, (int)margin.Top, (int)margin.Bottom);

            // The background must be transparent in order to use glass
            // WPF
            window.Background = Brushes.Transparent;

            return ExtendGlassFrame(hwnd, margins);
        }
示例#2
0
        public static bool ExtendGlassFrame(IntPtr hwnd, MARGINS margins)
        {
            // Can we draw glass?
            if (!DwmIsCompositionEnabled())
                return false;

            if (hwnd == IntPtr.Zero)
                throw new InvalidOperationException("Window must be shown before drawing glass");

            // The background must be transparent in order to use glass
            // Win32
            HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;

            DwmExtendFrameIntoClientArea(hwnd, ref margins);

            return true;
        }
示例#3
0
 static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);