From cfcaafca037f1936798fc619a9b7bfcdab8b59c2 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 8 Jul 2025 09:24:39 -0500 Subject: [PATCH] _NA --- src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs | 5 +++-- src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt | 6 ------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs index f8bcebc97e..41caf09a79 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs @@ -308,12 +308,13 @@ public sealed partial class MainWindow : WindowEx, // Then hide our HWND, to make sure that the OS gives the FG / focus back to another app // (there's no way for us to guess what the right hwnd might be, only the OS can do it right) - this.Hide(); + PInvoke.ShowWindow(_hwnd, SHOW_WINDOW_CMD.SW_HIDE); // TRICKY: show our HWND again. This will trick XAML into painting our // HWND again, so that we avoid the "flicker" caused by a WinUI3 app // window being first shown - this.Show(); + // SW_SHOWNA will prevent us for trying to fight the focus back + PInvoke.ShowWindow(_hwnd, SHOW_WINDOW_CMD.SW_SHOWNA); // Intentionally leave the window cloaked. So our window is "visible", // but also cloaked, so you can't see it. diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt index 698c67f9d7..35fafb4680 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt @@ -43,9 +43,3 @@ MessageBox DwmGetWindowAttribute DwmSetWindowAttribute DWM_CLOAKED_APP - -EnumWindows -IsWindowVisible -GetClientRect -GetWindowLong -WINDOW_EX_STYLE \ No newline at end of file