Skip to content

Commit 4e82724

Browse files
committed
Don't show overlay windows in Alt+Tab UI or taskbar
1 parent 4eb62d7 commit 4e82724

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

EnhancePoE/UI/RecipeStatusOverlay.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
MouseDown="Window_MouseDown"
1717
Background="Transparent"
1818
ShowInTaskbar="False"
19+
Loaded="OnLoaded"
1920
Left="{Binding Source={x:Static properties:Settings.Default}, Path=LeftOverlay, Mode=TwoWay}"
2021
Top="{Binding Source={x:Static properties:Settings.Default}, Path=TopOverlay, Mode=TwoWay}"
2122
d:DataContext="{d:DesignInstance Type={x:Type local:RecipeStatusOverlayViewModel}">

EnhancePoE/UI/RecipeStatusOverlay.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Windows;
55
using System.Windows.Input;
66
using EnhancePoE.Api;
7+
using EnhancePoE.Utils;
78

89
namespace EnhancePoE.UI;
910

@@ -33,6 +34,8 @@ public RecipeStatusOverlay( ItemSetManager itemSetManager, StashTabGetter stashT
3334
Properties.Settings.Default.PropertyChanged += OnSettingsChanged;
3435
}
3536

37+
private void OnLoaded( object sender, RoutedEventArgs e ) => Win32.MakeToolWindow( this );
38+
3639
private void OnSettingsChanged( object sender, PropertyChangedEventArgs e )
3740
{
3841
if ( e.PropertyName == nameof( Properties.Settings.OverlayMode ) )

EnhancePoE/UI/StashTabWindow.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
Topmost="True"
1414
MouseLeftButtonDown="OnMouseLeftButtonDown"
1515
ResizeMode="CanResizeWithGrip"
16+
Loaded="OnLoaded"
17+
ShowInTaskbar="False"
1618
Left="{Binding Source={x:Static properties:Settings.Default}, Path=LeftStashTabOverlay, Mode=TwoWay}"
1719
Top="{Binding Source={x:Static properties:Settings.Default}, Path=TopStashTabOverlay, Mode=TwoWay}"
1820
Height="{Binding Source={x:Static properties:Settings.Default}, Path=YStashTabOverlay, Mode=TwoWay}"

EnhancePoE/UI/StashTabWindow.xaml.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Windows;
44
using System.Windows.Controls;
55
using System.Windows.Input;
6-
using System.Windows.Interop;
76
using EnhancePoE.Utils;
87

98
namespace EnhancePoE.UI;
@@ -25,6 +24,8 @@ public StashTabWindow( ItemSetManager itemSetManager )
2524
MouseHook.MouseAction += OnMouseHookClick;
2625
}
2726

27+
private void OnLoaded( object sender, RoutedEventArgs e ) => Win32.MakeToolWindow( this );
28+
2829
public new virtual void Hide()
2930
{
3031
if ( !IsOpen )
@@ -80,14 +81,13 @@ protected override void OnSourceInitialized( EventArgs e )
8081

8182
private void MakeWindowClickThrough( bool clickThrough )
8283
{
83-
var handle = new WindowInteropHelper( this ).Handle;
8484
if ( clickThrough )
8585
{
86-
Win32.MakeTransparent( handle );
86+
Win32.MakeTransparent( this );
8787
}
8888
else
8989
{
90-
Win32.MakeNormal( handle );
90+
Win32.MakeNormal( this );
9191
}
9292
}
9393

EnhancePoE/Utils/Win32.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
using System;
22
using System.Runtime.InteropServices;
3+
using System.Windows;
4+
using System.Windows.Interop;
35

46
namespace EnhancePoE.Utils;
57

68
internal static class Win32
79
{
810
public const int WS_EX_TRANSPARENT = 0x00000020;
11+
public const int WS_EX_TOOLWINDOW = 0x00000080;
912
public const int GWL_EXSTYLE = -20;
1013

1114
[DllImport( "user32.dll" )]
@@ -14,15 +17,25 @@ internal static class Win32
1417
[DllImport( "user32.dll" )]
1518
public static extern int SetWindowLong( IntPtr hwnd, int index, int newStyle );
1619

17-
public static void MakeTransparent( IntPtr hwnd )
20+
public static void MakeTransparent( Window window )
1821
{
22+
var hwnd = new WindowInteropHelper( window ).Handle;
1923
int extendedStyle = GetWindowLong( hwnd, GWL_EXSTYLE );
2024
_ = SetWindowLong( hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT );
2125
}
2226

23-
public static void MakeNormal( IntPtr hwnd )
27+
public static void MakeNormal( Window window )
2428
{
29+
var hwnd = new WindowInteropHelper( window ).Handle;
2530
int extendedStyle = GetWindowLong( hwnd, GWL_EXSTYLE );
2631
_ = SetWindowLong( hwnd, GWL_EXSTYLE, extendedStyle & ~WS_EX_TRANSPARENT );
2732
}
33+
34+
// Ensures window does not show up in Alt+Tab or Win+Tab UI
35+
public static void MakeToolWindow( Window window )
36+
{
37+
var hwnd = new WindowInteropHelper( window ).Handle;
38+
int extendedStyle = GetWindowLong( hwnd, GWL_EXSTYLE );
39+
_ = SetWindowLong( hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TOOLWINDOW );
40+
}
2841
}

0 commit comments

Comments
 (0)