Skip to content

Commit 7fdfa6f

Browse files
committed
Fix #163
1 parent f85f2e3 commit 7fdfa6f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/core/contexts/win32windowcontext.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,16 @@ namespace QWK {
219219
return true;
220220
}
221221

222+
const auto windowStyles = ::GetWindowLongPtrW(hWnd, GWL_STYLE);
223+
const bool allowMaximize = windowStyles & WS_MAXIMIZEBOX;
224+
const bool allowMinimize = windowStyles & WS_MINIMIZEBOX;
225+
222226
const bool maxOrFull = isMaximized(hWnd) || isFullScreen(hWnd);
223227
::EnableMenuItem(hMenu, SC_CLOSE, (MF_BYCOMMAND | MFS_ENABLED));
224228
::EnableMenuItem(hMenu, SC_MAXIMIZE,
225-
(MF_BYCOMMAND | ((maxOrFull || fixedSize) ? MFS_DISABLED : MFS_ENABLED)));
229+
(MF_BYCOMMAND | ((maxOrFull || fixedSize || !allowMaximize) ? MFS_DISABLED : MFS_ENABLED)));
226230
::EnableMenuItem(hMenu, SC_RESTORE,
227-
(MF_BYCOMMAND | ((maxOrFull && !fixedSize) ? MFS_ENABLED : MFS_DISABLED)));
231+
(MF_BYCOMMAND | ((maxOrFull && !fixedSize && allowMaximize) ? MFS_ENABLED : MFS_DISABLED)));
228232
// The first menu item should be selected by default if the menu is brought
229233
// up by keyboard. I don't know how to pre-select a menu item but it seems
230234
// highlight can do the job. However, there's an annoying issue if we do
@@ -236,7 +240,7 @@ namespace QWK {
236240
// the menu look kind of weird. Currently I don't know how to fix this issue.
237241
::HiliteMenuItem(hWnd, hMenu, SC_RESTORE,
238242
(MF_BYCOMMAND | (selectFirstEntry ? MFS_HILITE : MFS_UNHILITE)));
239-
::EnableMenuItem(hMenu, SC_MINIMIZE, (MF_BYCOMMAND | MFS_ENABLED));
243+
::EnableMenuItem(hMenu, SC_MINIMIZE, (MF_BYCOMMAND | (allowMinimize ? MFS_ENABLED : MFS_DISABLED)));
240244
::EnableMenuItem(hMenu, SC_SIZE,
241245
(MF_BYCOMMAND | ((maxOrFull || fixedSize) ? MFS_DISABLED : MFS_ENABLED)));
242246
::EnableMenuItem(hMenu, SC_MOVE, (MF_BYCOMMAND | (maxOrFull ? MFS_DISABLED : MFS_ENABLED)));

0 commit comments

Comments
 (0)