private static void AffectWindowStyle( DependencyObject obj, DependencyPropertyChangedEventArgs args, ApiWindowStyles styles) { var window = obj as Window; if (window == null) { return; } ResetWindowStyle(window, styles, (bool)args.NewValue); }
private static void ResetWindowStyle([NotNull] Window window, ApiWindowStyles styles, bool set) { const int Flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER; var wih = new WindowInteropHelper(window); var style = (ApiWindowStyles)GetWindowLong(wih.EnsureHandle(), GWL_STYLE); if (set) { style |= styles; } else { style &= ~styles; } SetWindowLong(wih.Handle, GWL_STYLE, (IntPtr)style); SetWindowPos(wih.Handle, IntPtr.Zero, 0, 0, 0, 0, Flags); }