From 5312f64a79f9657ad0146c2a0346833bdd2888bc Mon Sep 17 00:00:00 2001 From: Antoine Aflalo <197810+Belphemur@users.noreply.github.com> Date: Sat, 4 May 2024 20:42:36 -0400 Subject: [PATCH] fix(banner/quickmenu): Don't show notification or quick menu in the ALT+TAB menu Fixes #1475 --- SoundSwitch.UI.Menu/Form/QuickMenu.cs | 15 +++++++++++++++ SoundSwitch/Framework/Banner/BannerForm.cs | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/SoundSwitch.UI.Menu/Form/QuickMenu.cs b/SoundSwitch.UI.Menu/Form/QuickMenu.cs index 6e79d4acad..6b059abeaa 100644 --- a/SoundSwitch.UI.Menu/Form/QuickMenu.cs +++ b/SoundSwitch.UI.Menu/Form/QuickMenu.cs @@ -37,6 +37,21 @@ internal QuickMenu() InitializeComponent(); _hideDisposeMethod = HideDispose; TopMost = true; + FormBorderStyle = FormBorderStyle.None; + ShowInTaskbar = false; + } + + protected override CreateParams CreateParams + { + get + { + var cp = base.CreateParams; + // turn on WS_EX_TOOLWINDOW style bit + // Used to hide the banner from alt+tab + // source: https://www.csharp411.com/hide-form-from-alttab/ + cp.ExStyle |= 0x80; + return cp; + } } /// diff --git a/SoundSwitch/Framework/Banner/BannerForm.cs b/SoundSwitch/Framework/Banner/BannerForm.cs index 73cb00d709..dd8882acba 100644 --- a/SoundSwitch/Framework/Banner/BannerForm.cs +++ b/SoundSwitch/Framework/Banner/BannerForm.cs @@ -56,9 +56,24 @@ public BannerForm() StartPosition = FormStartPosition.Manual; Bounds = screen.Bounds; TopMost = true; + FormBorderStyle = FormBorderStyle.None; + ShowInTaskbar = false; } protected override bool ShowWithoutActivation => true; + + protected override CreateParams CreateParams + { + get + { + var cp = base.CreateParams; + // turn on WS_EX_TOOLWINDOW style bit + // Used to hide the banner from alt+tab + // source: https://www.csharp411.com/hide-form-from-alttab/ + cp.ExStyle |= 0x80; + return cp; + } + } // /// // /// Override the parameters used to create the window handle.