From 76d986891f5046623308d0c7ea6cec96f5479125 Mon Sep 17 00:00:00 2001 From: Daniel Pedigo Date: Tue, 25 Aug 2015 19:51:38 -0600 Subject: [PATCH] Better fix for the alt tab issue that doesn't cause problems with virtual desktops (issue #1321) --- Hearthstone Deck Tracker/MainWindow/MainWindow.xaml | 2 +- Hearthstone Deck Tracker/MainWindow/MainWindow.xaml.cs | 8 ++++++++ Hearthstone Deck Tracker/Windows/OverlayWindow.xaml.cs | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Hearthstone Deck Tracker/MainWindow/MainWindow.xaml b/Hearthstone Deck Tracker/MainWindow/MainWindow.xaml index e4f6e1238e..acba421070 100644 --- a/Hearthstone Deck Tracker/MainWindow/MainWindow.xaml +++ b/Hearthstone Deck Tracker/MainWindow/MainWindow.xaml @@ -13,7 +13,7 @@ MinHeight="584" MinWidth="700" Closing="Window_Closing" Icon="..\Images\HearthstoneDeckTracker.ico" - StateChanged="MetroWindow_StateChanged" Loaded="MetroWindow_Loaded" + StateChanged="MetroWindow_StateChanged" Loaded="MetroWindow_Loaded" SourceInitialized="MetroWindow_SourceInitalized" BorderBrush="{DynamicResource AccentColorBrush}" BorderThickness="1" LocationChanged="MetroWindow_LocationChanged" SizeChanged="MetroWindow_SizeChanged"> diff --git a/Hearthstone Deck Tracker/MainWindow/MainWindow.xaml.cs b/Hearthstone Deck Tracker/MainWindow/MainWindow.xaml.cs index 897c482848..33618bffe1 100644 --- a/Hearthstone Deck Tracker/MainWindow/MainWindow.xaml.cs +++ b/Hearthstone Deck Tracker/MainWindow/MainWindow.xaml.cs @@ -1157,6 +1157,14 @@ private void MetroWindow_StateChanged(object sender, EventArgs e) MinimizeToTray(); } + private void MetroWindow_SourceInitalized(object sender, EventArgs e) + { + // we need to take ownership of the overlay to prevent it from appearing + // in the alt+tab switcher but we also need a valid window handle. + // this is the soonest we'll have one. + Overlay.Owner = this; + } + private async void Window_Closing(object sender, CancelEventArgs e) { try diff --git a/Hearthstone Deck Tracker/Windows/OverlayWindow.xaml.cs b/Hearthstone Deck Tracker/Windows/OverlayWindow.xaml.cs index 0359c5d43f..cacb622727 100644 --- a/Hearthstone Deck Tracker/Windows/OverlayWindow.xaml.cs +++ b/Hearthstone Deck Tracker/Windows/OverlayWindow.xaml.cs @@ -576,7 +576,7 @@ private void ReSizePosLists() private void Window_SourceInitialized_1(object sender, EventArgs e) { var hwnd = new WindowInteropHelper(this).Handle; - User32.SetWindowExStyle(hwnd, User32.WsExTransparent | User32.WsExToolWindow); + User32.SetWindowExStyle(hwnd, User32.WsExTransparent); } public void Update(bool refresh)