public static bool ExtendGlassFrame(Window AWindow, Thickness AThicknessMargin) { try { if (!DwmIsCompositionEnabled()) { return(false); } IntPtr LIntPtrHandle = new WindowInteropHelper(AWindow).Handle; if (LIntPtrHandle == IntPtr.Zero) { return(false); } AWindow.Background = Brushes.Transparent; HwndSource.FromHwnd(LIntPtrHandle).CompositionTarget.BackgroundColor = Colors.Transparent; StructMargins LStructMargins = new StructMargins(AThicknessMargin); DwmExtendFrameIntoClientArea(LIntPtrHandle, ref LStructMargins); } catch { return(false); } return(true); }
static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref StructMargins pMarInset);