diff --git a/src/ManagedShell.AppBar/AppBarWindow.cs b/src/ManagedShell.AppBar/AppBarWindow.cs
index ea72e7dd..b3f9e78a 100644
--- a/src/ManagedShell.AppBar/AppBarWindow.cs
+++ b/src/ManagedShell.AppBar/AppBarWindow.cs
@@ -136,7 +136,7 @@ public AppBarWindow(AppBarManager appBarManager, ExplorerHelper explorerHelper,
PropertyChanged += AppBarWindow_PropertyChanged;
ResizeMode = ResizeMode.NoResize;
- if (EnvironmentHelper.IsWindows11OrBetter)
+ if (EnvironmentHelper.EnableWin11DpiWorkaround && EnvironmentHelper.IsWindows11OrBetter)
{
// With Windows 11, we cannot use the normal way to hide from taskbar (setting as a tool window) because that breaks receiving WM_DPICHANGED.
ShowInTaskbar = false;
diff --git a/src/ManagedShell.Common/Helpers/EnvironmentHelper.cs b/src/ManagedShell.Common/Helpers/EnvironmentHelper.cs
index 0c007cd3..f1b38a0b 100644
--- a/src/ManagedShell.Common/Helpers/EnvironmentHelper.cs
+++ b/src/ManagedShell.Common/Helpers/EnvironmentHelper.cs
@@ -11,6 +11,8 @@ public static class EnvironmentHelper
private static int osVersionMinor = 0;
private static int osVersionBuild = 0;
+ public static bool EnableWin11DpiWorkaround;
+
private static void getOSVersion()
{
osVersionMajor = Environment.OSVersion.Version.Major;
diff --git a/src/ManagedShell.Common/Helpers/WindowHelper.cs b/src/ManagedShell.Common/Helpers/WindowHelper.cs
index 9944d2bc..1a369238 100644
--- a/src/ManagedShell.Common/Helpers/WindowHelper.cs
+++ b/src/ManagedShell.Common/Helpers/WindowHelper.cs
@@ -104,7 +104,7 @@ public static IntPtr GetLowestDesktopChildHwnd()
public static void HideWindowFromTasks(IntPtr hWnd)
{
int style = GetWindowLong(hWnd, WindowLongFlags.GWL_EXSTYLE) & ~(int)ExtendedWindowStyles.WS_EX_APPWINDOW;
- if (EnvironmentHelper.IsWindows11OrBetter)
+ if (EnvironmentHelper.EnableWin11DpiWorkaround && EnvironmentHelper.IsWindows11OrBetter)
{
// If the window has a Hidden Window owner, set the owner as a tool window instead so that we still receive WM_DPICHANGED on Windows 11.
// Hidden Window is the owner when ShowInTaskbar=false. Unfortunately, the window will not be hidden from Task Manager.
diff --git a/src/ManagedShell/ShellConfig.cs b/src/ManagedShell/ShellConfig.cs
index 15336c47..de92e081 100644
--- a/src/ManagedShell/ShellConfig.cs
+++ b/src/ManagedShell/ShellConfig.cs
@@ -67,7 +67,16 @@ public struct ShellConfig
/// - Otherwise, the string follows the format: "PathToExe:UID"
///
public string[] PinnedNotifyIcons;
-
+
#endregion
+
+ ///
+ /// Controls whether the workaround for Windows 11 DPI change notification workaround for AppBars is enabled.
+ ///
+ /// In Windows 11, tool windows (which AppBars are, to hide from the taskbar, alt-tab, and Task Manager) do not receive DPI change notifications.
+ /// To work around this, we can instead give the AppBar an owner window that has WS_EX_TOOLWINDOW, so the AppBar does not need it.
+ /// Unfortunately, this results in the AppBar displaying in Task Manager, as well as some unpredictable Z-order issues due to the ownership relationship.
+ ///
+ public bool EnableWin11DpiWorkaround;
}
}
diff --git a/src/ManagedShell/ShellManager.cs b/src/ManagedShell/ShellManager.cs
index 5290c675..4a0ebbbe 100644
--- a/src/ManagedShell/ShellManager.cs
+++ b/src/ManagedShell/ShellManager.cs
@@ -17,7 +17,9 @@ public class ShellManager : IDisposable
EnableTrayService = true,
AutoStartTrayService = true,
- PinnedNotifyIcons = NotificationArea.DEFAULT_PINNED
+ PinnedNotifyIcons = NotificationArea.DEFAULT_PINNED,
+
+ EnableWin11DpiWorkaround = false
};
///
@@ -33,6 +35,8 @@ public ShellManager() : this(DefaultShellConfig)
/// A ShellConfig struct containing desired initialization parameters.
public ShellManager(ShellConfig config)
{
+ EnvironmentHelper.EnableWin11DpiWorkaround = config.EnableWin11DpiWorkaround;
+
if (config.EnableTrayService)
{
TrayService = new TrayService();