Ejemplo n.º 1
0
        public static bool ExtendGlass(Window win, int left, int right, int top, int bottom)
        {
            try
            {
                if (!DwmIsCompositionEnabled())
                {
                    return(false);
                }
                // Obtain the window handle for WPF application
                WindowInteropHelper windowInterop = new WindowInteropHelper(win);
                IntPtr     windowHandle           = windowInterop.Handle;
                HwndSource mainWindowSrc          = HwndSource.FromHwnd(windowHandle);
                mainWindowSrc.CompositionTarget.BackgroundColor = Colors.Transparent;

                VistaGlassHelper.Margins margins =
                    VistaGlassHelper.GetDpiAdjustedMargins(windowHandle, left, right, top, bottom);

                int returnVal = VistaGlassHelper.DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);

                if (returnVal < 0)
                {
                    throw new NotSupportedException("Operation failed.");
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     try
     {
         VistaGlassHelper.ExtendGlass(this, -1, -1, -1);
     }
     // If not Vista, paint background white.
     catch //(DllNotFoundException)
     {
         Background = Brushes.White;
     }
 }
Ejemplo n.º 3
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     try
     {
         VistaGlassHelper.ExtendGlass(this, 5, 5, (int)topBar.ActualHeight + 5, 5);
     }
     // If not Vista, paint background white.
     catch //(DllNotFoundException)
     {
         this.Background = Brushes.White;
     }
 }