diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutOverlayWindow.xaml b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutOverlayWindow.xaml index 4710403e7c..01b276518c 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutOverlayWindow.xaml +++ b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutOverlayWindow.xaml @@ -12,4 +12,5 @@ ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="True" + Loaded="Window_Loaded" Background="{DynamicResource BackdropBrush}"/> \ No newline at end of file diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutOverlayWindow.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutOverlayWindow.xaml.cs index 0f5e8e762b..14f3498bb3 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutOverlayWindow.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutOverlayWindow.xaml.cs @@ -2,9 +2,7 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; using System.Windows; -using System.Windows.Media; namespace FancyZonesEditor { @@ -17,5 +15,10 @@ namespace FancyZonesEditor { InitializeComponent(); } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + Utils.NativeMethods.SetWindowStyleToolWindow(this); + } } } diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Utils/NativeMethods.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Utils/NativeMethods.cs new file mode 100644 index 0000000000..09bdd7c2a7 --- /dev/null +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Utils/NativeMethods.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Interop; + +namespace FancyZonesEditor.Utils +{ + internal class NativeMethods + { + [DllImport("user32.dll", SetLastError = true)] + private static extern int GetWindowLong(IntPtr hWnd, int nIndex); + + [DllImport("user32.dll")] + private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + +#pragma warning disable SA1310 // Field names should not contain underscore + private const int GWL_EX_STYLE = -20; + private const int WS_EX_APPWINDOW = 0x00040000; + private const int WS_EX_TOOLWINDOW = 0x00000080; +#pragma warning restore SA1310 // Field names should not contain underscore + + public static void SetWindowStyleToolWindow(Window hwnd) + { + var helper = new WindowInteropHelper(hwnd).Handle; + SetWindowLong(helper, GWL_EX_STYLE, (GetWindowLong(helper, GWL_EX_STYLE) | WS_EX_TOOLWINDOW) & ~WS_EX_APPWINDOW); + } + } +}