private IntPtr _HandleNCCalcSize(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled) { if (_chromeInfo.SacrificialEdge != SacrificialEdge.None) { var windowResizeBorderThicknessDevice = DpiHelper.LogicalThicknessToDevice(SystemParameters2.Current.WindowResizeBorderThickness); var rcClientArea = (RECT)Marshal.PtrToStructure(lParam, typeof(RECT)); if (Utility.IsFlagSet((int)_chromeInfo.SacrificialEdge, (int)SacrificialEdge.Top)) { rcClientArea.Top += (int)windowResizeBorderThicknessDevice.Top; } if (Utility.IsFlagSet((int)_chromeInfo.SacrificialEdge, (int)SacrificialEdge.Left)) { rcClientArea.Left += (int)windowResizeBorderThicknessDevice.Left; } if (Utility.IsFlagSet((int)_chromeInfo.SacrificialEdge, (int)SacrificialEdge.Bottom)) { rcClientArea.Bottom -= (int)windowResizeBorderThicknessDevice.Bottom; } if (Utility.IsFlagSet((int)_chromeInfo.SacrificialEdge, (int)SacrificialEdge.Right)) { rcClientArea.Right -= (int)windowResizeBorderThicknessDevice.Right; } Marshal.StructureToPtr(rcClientArea, lParam, false); } handled = true; return(new IntPtr((int)WVR.REDRAW)); }
private IntPtr _HandleNCCalcSize(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled) { if (this._chromeInfo.NonClientFrameEdges != NonClientFrameEdges.None) { DpiScale dpi = this._window.GetDpi(); Thickness thickness = DpiHelper.LogicalThicknessToDevice(SystemParameters.WindowResizeBorderThickness, dpi.DpiScaleX, dpi.DpiScaleY); RECT rect = (RECT)Marshal.PtrToStructure(lParam, typeof(RECT)); if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 2)) { rect.Top += (int)thickness.Top; } if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 1)) { rect.Left += (int)thickness.Left; } if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 8)) { rect.Bottom -= (int)thickness.Bottom; } if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 4)) { rect.Right -= (int)thickness.Right; } Marshal.StructureToPtr(rect, lParam, false); } handled = true; IntPtr zero = IntPtr.Zero; if (wParam.ToInt32() != 0) { zero = new IntPtr(768); } return(zero); }
private void _ExtendGlassFrame() { Assert.IsNotNull(_window); if (!Utility.IsOSVistaOrNewer) { return; } if (IntPtr.Zero == _hwnd) { return; } if (!NativeMethods.DwmIsCompositionEnabled()) { _hwndSource.CompositionTarget.BackgroundColor = SystemColors.WindowColor; } else { _hwndSource.CompositionTarget.BackgroundColor = Colors.Transparent; var deviceGlassThickness = DpiHelper.LogicalThicknessToDevice(_chromeInfo.GlassFrameThickness); if (_chromeInfo.SacrificialEdge != SacrificialEdge.None) { var windowResizeBorderThicknessDevice = DpiHelper.LogicalThicknessToDevice(SystemParameters2.Current.WindowResizeBorderThickness); if (Utility.IsFlagSet((int)_chromeInfo.SacrificialEdge, (int)SacrificialEdge.Top)) { deviceGlassThickness.Top -= windowResizeBorderThicknessDevice.Top; deviceGlassThickness.Top = Math.Max(0, deviceGlassThickness.Top); } if (Utility.IsFlagSet((int)_chromeInfo.SacrificialEdge, (int)SacrificialEdge.Left)) { deviceGlassThickness.Left -= windowResizeBorderThicknessDevice.Left; deviceGlassThickness.Left = Math.Max(0, deviceGlassThickness.Left); } if (Utility.IsFlagSet((int)_chromeInfo.SacrificialEdge, (int)SacrificialEdge.Bottom)) { deviceGlassThickness.Bottom -= windowResizeBorderThicknessDevice.Bottom; deviceGlassThickness.Bottom = Math.Max(0, deviceGlassThickness.Bottom); } if (Utility.IsFlagSet((int)_chromeInfo.SacrificialEdge, (int)SacrificialEdge.Right)) { deviceGlassThickness.Right -= windowResizeBorderThicknessDevice.Right; deviceGlassThickness.Right = Math.Max(0, deviceGlassThickness.Right); } } var dwmMargin = new MARGINS { cxLeftWidth = (int)Math.Ceiling(deviceGlassThickness.Left), cxRightWidth = (int)Math.Ceiling(deviceGlassThickness.Right), cyTopHeight = (int)Math.Ceiling(deviceGlassThickness.Top), cyBottomHeight = (int)Math.Ceiling(deviceGlassThickness.Bottom), }; NativeMethods.DwmExtendFrameIntoClientArea(_hwnd, ref dwmMargin); } }
private void _ExtendGlassFrame() { if (!Utility.IsOSVistaOrNewer) { return; } if (IntPtr.Zero == this._hwnd) { return; } if (!NativeMethods.DwmIsCompositionEnabled()) { this._hwndSource.CompositionTarget.BackgroundColor = SystemColors.WindowColor; return; } DpiScale dpi = this._window.GetDpi(); this._hwndSource.CompositionTarget.BackgroundColor = Colors.Transparent; Thickness thickness = DpiHelper.LogicalThicknessToDevice(this._chromeInfo.GlassFrameThickness, dpi.DpiScaleX, dpi.DpiScaleY); if (this._chromeInfo.NonClientFrameEdges != NonClientFrameEdges.None) { Thickness thickness2 = DpiHelper.LogicalThicknessToDevice(SystemParameters.WindowResizeBorderThickness, dpi.DpiScaleX, dpi.DpiScaleY); if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 2)) { thickness.Top -= thickness2.Top; thickness.Top = Math.Max(0.0, thickness.Top); } if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 1)) { thickness.Left -= thickness2.Left; thickness.Left = Math.Max(0.0, thickness.Left); } if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 8)) { thickness.Bottom -= thickness2.Bottom; thickness.Bottom = Math.Max(0.0, thickness.Bottom); } if (Utility.IsFlagSet((int)this._chromeInfo.NonClientFrameEdges, 4)) { thickness.Right -= thickness2.Right; thickness.Right = Math.Max(0.0, thickness.Right); } } MARGINS margins = new MARGINS { cxLeftWidth = (int)Math.Ceiling(thickness.Left), cxRightWidth = (int)Math.Ceiling(thickness.Right), cyTopHeight = (int)Math.Ceiling(thickness.Top), cyBottomHeight = (int)Math.Ceiling(thickness.Bottom) }; NativeMethods.DwmExtendFrameIntoClientArea(this._hwnd, ref margins); }