From 2ac464279a91e5f5cb1ac28e609844b6cf7faaa8 Mon Sep 17 00:00:00 2001 From: Davide Giacometti <25966642+davidegiacometti@users.noreply.github.com> Date: Sun, 4 May 2025 13:04:29 +0200 Subject: [PATCH] [CmdPal] Prevent maximizing (#39220) Prevent CmdPal window from maximizing when user double-click the title bar area. Closes: #39096 --- .../cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs | 10 ++++------ .../cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt | 2 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs index ce20c9be77..e80792723d 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs @@ -404,11 +404,6 @@ public sealed partial class MainWindow : Window, // know till the message is being handled. WeakReferenceMessenger.Default.Send(new(commandId, _hwnd)); -#pragma warning disable SA1310 // Field names should not contain underscore - private const uint DOT_KEY = 0xBE; - private const uint WM_HOTKEY = 0x0312; -#pragma warning restore SA1310 // Field names should not contain underscore - private void UnregisterHotkeys() { _keyboardListener.ClearHotkeys(); @@ -502,7 +497,10 @@ public sealed partial class MainWindow : Window, { switch (uMsg) { - case WM_HOTKEY: + // Prevent the window from maximizing when double-clicking the title bar area + case PInvoke.WM_NCLBUTTONDBLCLK: + return (LRESULT)IntPtr.Zero; + case PInvoke.WM_HOTKEY: { var hotkeyIndex = (int)wParam.Value; if (hotkeyIndex < _hotkeys.Count) diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt index 4db59d7070..285bcff8c8 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/NativeMethods.txt @@ -25,6 +25,8 @@ SHCreateStreamOnFileEx CoAllowSetForegroundWindow SHCreateStreamOnFileEx SHLoadIndirectString +WM_HOTKEY +WM_NCLBUTTONDBLCLK Shell_NotifyIcon LoadIcon