[Common]fix fancy zones exclusion (#16041)

replace WS_POPUP with WS_EX_TOOLWINDOW
This commit is contained in:
Davide Giacometti
2022-02-07 20:16:36 +01:00
committed by GitHub
parent 49a2218358
commit e284b07da7
10 changed files with 22 additions and 22 deletions

View File

@@ -10,7 +10,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ControlzEx" Version="4.4.0" /> <PackageReference Include="ControlzEx" Version="5.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -31,7 +31,7 @@ namespace ColorPicker
protected override void OnSourceInitialized(EventArgs e) protected override void OnSourceInitialized(EventArgs e)
{ {
base.OnSourceInitialized(e); base.OnSourceInitialized(e);
NativeMethods.SetPopupStyle(this); NativeMethods.SetToolWindowStyle(this);
} }
} }
} }

View File

@@ -59,7 +59,7 @@
<PackageReference Include="System.ComponentModel.Composition" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Composition" Version="5.0.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" /> <PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="System.IO.Abstractions" Version="12.2.5" /> <PackageReference Include="System.IO.Abstractions" Version="12.2.5" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" /> <PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -15,8 +15,8 @@ namespace ColorPicker
// will have to rename // will have to rename
public static class NativeMethods public static class NativeMethods
{ {
private const int GWL_STYLE = -16; private const int GWL_EX_STYLE = -20;
private const int WS_POPUP = 1 << 31; // 0x80000000 private const int WS_EX_TOOLWINDOW = 0x00000080;
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Interop")] [System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Interop")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Interop")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Interop")]
@@ -180,10 +180,10 @@ namespace ColorPicker
[DllImport("user32.dll")] [DllImport("user32.dll")]
internal static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); internal static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
internal static void SetPopupStyle(Window win) internal static void SetToolWindowStyle(Window win)
{ {
var hwnd = new WindowInteropHelper(win).Handle; var hwnd = new WindowInteropHelper(win).Handle;
_ = SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) | WS_POPUP); _ = SetWindowLong(hwnd, GWL_EX_STYLE, GetWindowLong(hwnd, GWL_EX_STYLE) | WS_EX_TOOLWINDOW);
} }
} }
} }

View File

@@ -64,7 +64,7 @@
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0"> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="ModernWpfUI" Version="0.9.4" /> <PackageReference Include="ModernWpfUI" Version="0.9.4" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>

View File

@@ -14,14 +14,13 @@ using Point = System.Windows.Point;
namespace PowerLauncher.Helper namespace PowerLauncher.Helper
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Matching COM")]
public static class WindowsInteropHelper public static class WindowsInteropHelper
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Matching COM")]
private const int GWL_STYLE = -16; // WPF's Message code for Title Bar's Style private const int GWL_STYLE = -16; // WPF's Message code for Title Bar's Style
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Matching COM")] private const int GWL_EX_STYLE = -20;
private const int WS_SYSMENU = 0x80000; // WPF's Message code for System Menu private const int WS_SYSMENU = 0x80000; // WPF's Message code for System Menu
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Matching COM")] private const int WS_EX_TOOLWINDOW = 0x00000080;
private const int WS_POPUP = 1 << 31; // 0x80000000
private static IntPtr _hwnd_shell; private static IntPtr _hwnd_shell;
private static IntPtr _hwnd_desktop; private static IntPtr _hwnd_desktop;
@@ -172,12 +171,12 @@ namespace PowerLauncher.Helper
} }
/// <summary> /// <summary>
/// Set WS_POPUP to make FancyZones ignoring the Window /// Set WS_EX_TOOLWINDOW to make FancyZones ignoring the Window
/// </summary> /// </summary>
public static void SetPopupStyle(Window win) internal static void SetToolWindowStyle(Window win)
{ {
var hwnd = new WindowInteropHelper(win).Handle; var hwnd = new WindowInteropHelper(win).Handle;
_ = NativeMethods.SetWindowLong(hwnd, GWL_STYLE, NativeMethods.GetWindowLong(hwnd, GWL_STYLE) | WS_POPUP); _ = NativeMethods.SetWindowLong(hwnd, GWL_EX_STYLE, NativeMethods.GetWindowLong(hwnd, GWL_EX_STYLE) | WS_EX_TOOLWINDOW);
} }
/// <summary> /// <summary>

View File

@@ -78,7 +78,7 @@ namespace PowerLauncher
protected override void OnSourceInitialized(EventArgs e) protected override void OnSourceInitialized(EventArgs e)
{ {
base.OnSourceInitialized(e); base.OnSourceInitialized(e);
WindowsInteropHelper.SetPopupStyle(this); WindowsInteropHelper.SetToolWindowStyle(this);
} }
private void CheckForFirstDelete(object sender, ElapsedEventArgs e) private void CheckForFirstDelete(object sender, ElapsedEventArgs e)

View File

@@ -101,7 +101,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.1" /> <PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.1" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.2" /> <PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="ModernWpfUI" Version="0.9.4" /> <PackageReference Include="ModernWpfUI" Version="0.9.4" />
<PackageReference Include="System.Runtime" Version="4.3.1" /> <PackageReference Include="System.Runtime" Version="4.3.1" />
<PackageReference Include="Microsoft.VCRTForwarders.140" Version="1.0.6" /> <PackageReference Include="Microsoft.VCRTForwarders.140" Version="1.0.6" />

View File

@@ -89,7 +89,7 @@ namespace PowerToys.Settings
{ {
base.OnSourceInitialized(e); base.OnSourceInitialized(e);
var hwnd = new WindowInteropHelper(this).Handle; var hwnd = new WindowInteropHelper(this).Handle;
NativeMethods.SetPopupStyle(hwnd); NativeMethods.SetToolWindowStyle(hwnd);
} }
} }
} }

View File

@@ -5,13 +5,14 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Windows.UI.Xaml;
namespace Microsoft.PowerToys.Settings.UI.Helpers namespace Microsoft.PowerToys.Settings.UI.Helpers
{ {
public static class NativeMethods public static class NativeMethods
{ {
private const int GWL_STYLE = -16; private const int GWL_EX_STYLE = -20;
private const int WS_POPUP = 1 << 31; // 0x80000000 private const int WS_EX_TOOLWINDOW = 0x00000080;
internal const int SPI_GETDESKWALLPAPER = 0x0073; internal const int SPI_GETDESKWALLPAPER = 0x0073;
[DllImport("user32.dll")] [DllImport("user32.dll")]
@@ -44,9 +45,9 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SystemParametersInfo(int uiAction, int uiParam, StringBuilder pvParam, int fWinIni); internal static extern bool SystemParametersInfo(int uiAction, int uiParam, StringBuilder pvParam, int fWinIni);
public static void SetPopupStyle(IntPtr hwnd) public static void SetToolWindowStyle(IntPtr hwnd)
{ {
_ = SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) | WS_POPUP); _ = SetWindowLong(hwnd, GWL_EX_STYLE, GetWindowLong(hwnd, GWL_EX_STYLE) | WS_EX_TOOLWINDOW);
} }
} }
} }