mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Block window maximize and prevent resizing in WndProc
This commit is contained in:
parent
a06cb43540
commit
2b4e95e64a
2 changed files with 27 additions and 1 deletions
|
|
@ -163,6 +163,13 @@ namespace Flow.Launcher.Infrastructure
|
||||||
SetWindowStyle(hwnd, WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, (int)newExStyle);
|
SetWindowStyle(hwnd, WINDOW_LONG_PTR_INDEX.GWL_EXSTYLE, (int)newExStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void BlockWindowMaximize(Window window, HwndSourceHook hook)
|
||||||
|
{
|
||||||
|
var handle = GetWindowHandle(window, true);
|
||||||
|
var hwndSource = HwndSource.FromHwnd(handle);
|
||||||
|
hwndSource.AddHook(hook);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Restore window display in the Alt+Tab window list.
|
/// Restore window display in the Alt+Tab window list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -490,6 +490,12 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
#region Window WndProc
|
#region Window WndProc
|
||||||
|
|
||||||
|
private const int WM_NCLBUTTONDBLCLK = 0x00A3;
|
||||||
|
private const int WM_SYSCOMMAND = 0x0112;
|
||||||
|
private const int SC_MAXIMIZE = 0xF030;
|
||||||
|
private const int SC_RESTORE = 0xF120;
|
||||||
|
private const int SC_MINIMIZE = 0xF020;
|
||||||
|
|
||||||
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||||
{
|
{
|
||||||
if (msg == Win32Helper.WM_ENTERSIZEMOVE)
|
if (msg == Win32Helper.WM_ENTERSIZEMOVE)
|
||||||
|
|
@ -541,7 +547,20 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
if (msg == WM_NCLBUTTONDBLCLK)
|
||||||
|
{
|
||||||
|
SizeToContent = SizeToContent.Height;
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
else if (msg == WM_SYSCOMMAND)
|
||||||
|
{
|
||||||
|
int command = wParam.ToInt32() & 0xFFF0;
|
||||||
|
if (command == SC_MAXIMIZE || command == SC_MINIMIZE)
|
||||||
|
{
|
||||||
|
SizeToContent = SizeToContent.Height;
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue