From 95354d80bd432618180e3767fab7dd4363f7ddfd Mon Sep 17 00:00:00 2001 From: vasijob225 Date: Thu, 30 Jan 2025 21:01:55 +0100 Subject: [PATCH] app: [Windows] hide the maximize button when MaxSize is set Also, disable window frame resizing when MaxSize equals MinSize. Fixes: https://todo.sr.ht/~eliasnaur/gio/631 Signed-off-by: vasijob225 --- app/os_windows.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/os_windows.go b/app/os_windows.go index 733acde9..e99b829a 100644 --- a/app/os_windows.go +++ b/app/os_windows.go @@ -750,6 +750,16 @@ func (w *window) Configure(options []Option) { swpStyle |= windows.SWP_NOMOVE | windows.SWP_NOSIZE showMode = windows.SW_SHOWMAXIMIZED } + + // Disable maximize button if MaxSize is set. + if cnf.MaxSize != (image.Point{X: 0, Y: 0}) { + style &^= windows.WS_MAXIMIZEBOX + // Disable window resizing if MinSize and MaxSize are equal. + if cnf.MinSize == cnf.MaxSize { + style &^= windows.WS_THICKFRAME + } + } + windows.SetWindowLong(w.hwnd, windows.GWL_STYLE, style) windows.SetWindowPos(w.hwnd, 0, x, y, width, height, swpStyle) windows.ShowWindow(w.hwnd, showMode)