From dcb9fe55a1cdcda2fb9a7eefed722a64a8135de0 Mon Sep 17 00:00:00 2001 From: David Brett Date: Mon, 15 Jun 2026 10:19:40 +0200 Subject: [PATCH 1/4] Fix titlebar close button not working in MessageBoxEx --- Flow.Launcher/MessageBoxEx.xaml.cs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher/MessageBoxEx.xaml.cs b/Flow.Launcher/MessageBoxEx.xaml.cs index c50c732396e..9a8b4f0bc76 100644 --- a/Flow.Launcher/MessageBoxEx.xaml.cs +++ b/Flow.Launcher/MessageBoxEx.xaml.cs @@ -191,13 +191,26 @@ private void Button_Cancel(object sender, RoutedEventArgs e) { e.Handled = true; - if (_button == MessageBoxButton.YesNo) - // Follow System.Windows.MessageBox behavior - return; - else if (_button == MessageBoxButton.OK) - _result = MessageBoxResult.OK; - else - _result = MessageBoxResult.Cancel; + // Replicates System.Windows.MessageBox behavior + // https://learn.microsoft.com/en-us/dotnet/api/system.windows.messageboxresult#remarks + + switch (_button) + { + // For YesNo, the windows MessageBox disables the close button entirely. + // Since we don't have that we fall back to returning No. + case MessageBoxButton.YesNo: + _result = MessageBoxResult.No; + break; + case MessageBoxButton.OK: + _result = MessageBoxResult.OK; + break; + case MessageBoxButton.OKCancel: + case MessageBoxButton.YesNoCancel: + default: + _result = MessageBoxResult.Cancel; + break; + } + msgBox.Close(); msgBox = null; } From 0702aebbe5acb180c5810c860fcee6a16ac9c271 Mon Sep 17 00:00:00 2001 From: David Brett Date: Mon, 15 Jun 2026 12:41:35 +0200 Subject: [PATCH 2/4] Disable AeroCaptionButtons when using CustomWindowTitleBar This lets us properly disable the close button Previously even when we hid the custom one the default one was then clickable underneath --- .../Controls/CustomWindowTitleBar.xaml.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Flow.Launcher/Resources/Controls/CustomWindowTitleBar.xaml.cs b/Flow.Launcher/Resources/Controls/CustomWindowTitleBar.xaml.cs index 05e3148a939..7048a257248 100644 --- a/Flow.Launcher/Resources/Controls/CustomWindowTitleBar.xaml.cs +++ b/Flow.Launcher/Resources/Controls/CustomWindowTitleBar.xaml.cs @@ -3,6 +3,7 @@ using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Shell; namespace Flow.Launcher.Resources.Controls { @@ -113,6 +114,7 @@ public WindowStateChangedEventArgs(WindowState previousState, WindowState curren private Window _hostWindow; private WindowState _lastNonMinimizedWindowState = WindowState.Normal; + private bool? _savedUseAeroCaptionButtons; private Button MinimizeButtonElement => FindName("MinimizeButton") as Button; private Button MaximizeButtonElement => FindName("MaximizeButton") as Button; @@ -242,6 +244,14 @@ private void AttachToHostWindow() return; } + // Disable system caption buttons since this control provides custom ones + var chrome = WindowChrome.GetWindowChrome(_hostWindow); + if (chrome != null) + { + _savedUseAeroCaptionButtons = chrome.UseAeroCaptionButtons; + chrome.UseAeroCaptionButtons = false; + } + if (IconSource is null) { IconSource = _hostWindow.Icon ?? DefaultWindowIcon; @@ -269,6 +279,17 @@ private void DetachFromHostWindow() return; } + // Restore original system caption buttons if we disabled them + if (_savedUseAeroCaptionButtons.HasValue) + { + var chrome = WindowChrome.GetWindowChrome(_hostWindow); + if (chrome != null) + { + chrome.UseAeroCaptionButtons = _savedUseAeroCaptionButtons.Value; + } + _savedUseAeroCaptionButtons = null; + } + _hostWindow.StateChanged -= HostWindow_StateChanged; _hostWindow.Activated -= HostWindow_Activated; _hostWindow.Closed -= HostWindow_Closed; From 9e5fd69d55c441e4b610303f795fe0b3ab8df3e8 Mon Sep 17 00:00:00 2001 From: David Brett Date: Mon, 15 Jun 2026 12:55:07 +0200 Subject: [PATCH 3/4] Hide close button in MessageBoxEx when type is YesNo Since its should be unreachable we can safely go back to refusing to close the window if that button is somehow called when type is YesNo --- Flow.Launcher/MessageBoxEx.xaml | 1 + Flow.Launcher/MessageBoxEx.xaml.cs | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/MessageBoxEx.xaml b/Flow.Launcher/MessageBoxEx.xaml index c7e39b97188..e56e826ac10 100644 --- a/Flow.Launcher/MessageBoxEx.xaml +++ b/Flow.Launcher/MessageBoxEx.xaml @@ -33,6 +33,7 @@