🔀 禁用窗口最大化

This commit is contained in:
BookerLiu
2023-04-23 20:58:12 +08:00
parent 2df6582f83
commit ac8302280f
9 changed files with 31 additions and 4 deletions

View File

@@ -63,6 +63,21 @@ namespace GeekDesk.Util
[DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
private const int GWL_STYLE = -16;
private const int WS_MAXIMIZEBOX = 0x10000;
public static void DisableMaxWindow(Window window)
{
var hwnd = new WindowInteropHelper(window).Handle;
var value = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE, (int)(value & ~WS_MAXIMIZEBOX));
}
public static void SetOwner(Window window, Window parentWindow)
{