Пример #1
0
        public void extendFrame(int top, int bottom, int left, int right, Window window)
        {
            try
            {
                //set the form background to transparent
                window.Background = Brushes.Transparent;
                // Get the window handle
                IntPtr     mainWindowPtr = new WindowInteropHelper(window).Handle;
                HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
                mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);

                // Get the system dpi values
                System.Drawing.Graphics desktop = System.Drawing.Graphics.FromHwnd(mainWindowPtr);
                float DpiX  = desktop.DpiX;
                float pDpiY = desktop.DpiY;

                // Set Margins
                Margins margins = new Margins();

                margins.Left   = Convert.ToInt32((left + 5) * (DpiX / 96));
                margins.Right  = Convert.ToInt32((right + 5) * (DpiX / 96));
                margins.Top    = Convert.ToInt32((top + 5) * (DpiX / 96));
                margins.Bottom = Convert.ToInt32((bottom + 5) * (DpiX / 96));

                int check = GlassApi.DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);

                if (check < 0)
                {
                    //Cannot extend frame so set background to default
                    window.Background = defaultColor;
                }
            }
            // If aero is not supported paint the background default
            catch (DllNotFoundException)
            {
                window.Background = defaultColor;
            }
        }
Пример #2
0
 internal static extern int DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins);
Пример #3
0
 static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMarInset);
Пример #4
0
        public void extendFrame(int top, int bottom, int left, int right,Window window)
        {
            try
            {
                //set the form background to transparent
                window.Background = Brushes.Transparent;
                // Get the window handle
                IntPtr mainWindowPtr = new WindowInteropHelper(window).Handle;
                HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
                mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);

                // Get the system dpi values
                System.Drawing.Graphics desktop = System.Drawing.Graphics.FromHwnd(mainWindowPtr);
                float DpiX = desktop.DpiX;
                float pDpiY = desktop.DpiY;

                // Set Margins
                Margins margins = new Margins();

                margins.Left = Convert.ToInt32((left + 5) * (DpiX / 96));
                margins.Right = Convert.ToInt32((right + 5) * (DpiX / 96));
                margins.Top = Convert.ToInt32((top + 5) * (DpiX / 96));
                margins.Bottom = Convert.ToInt32((bottom + 5) * (DpiX / 96));

                int check = GlassApi.DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);

                if (check < 0)
                {
                    //Cannot extend frame so set background to default
                    window.Background = defaultColor;
                }
            }
            // If aero is not supported paint the background default
            catch (DllNotFoundException)
            {
                window.Background = defaultColor;
            }
        }
Пример #5
0
 public static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref Margins pMarInset);
Пример #6
0
 internal static extern int DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins);