From c02289a08add0b7096be8343e3aaeb675a62d133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 10 Jul 2024 17:45:21 +0200 Subject: [PATCH] [UXTHEME][NTUSER] Check class style for CS_NOCLOSE instead of window style (#7130) CORE-11569, CORE-19684 Addendum to commit 71bed0f5f8 (PR #7123). The problem in uxtheme was introduced in commit 685084b63c (as part of a fix for CORE-17203), because it was a copy-paste and adaptation of the corresponding code in `ntuser/nonclient.c!NC_DoButton()`. The bugs in `win32ss/user/ntuser/defwnd.c` (and `nonclient.c` as fixed by the previous commit) were in turn introduced from the migration of menu and related code from user32 to win32k, see commit 6dfa71c487 (r68904). --- dll/win32/uxtheme/nonclient.c | 2 +- win32ss/user/ntuser/defwnd.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dll/win32/uxtheme/nonclient.c b/dll/win32/uxtheme/nonclient.c index 441e27c4cf9..cc27e22eb0b 100644 --- a/dll/win32/uxtheme/nonclient.c +++ b/dll/win32/uxtheme/nonclient.c @@ -297,7 +297,7 @@ ThemeDrawCaptionButton(PDRAW_CONTEXT pcontext, case CLOSEBUTTON: SysMenu = GetSystemMenu(pcontext->hWnd, FALSE); MenuState = GetMenuState(SysMenu, SC_CLOSE, MF_BYCOMMAND); - if (!(pcontext->wi.dwStyle & WS_SYSMENU) || (MenuState & (MF_GRAYED | MF_DISABLED)) || pcontext->wi.dwStyle & CS_NOCLOSE) + if (!(pcontext->wi.dwStyle & WS_SYSMENU) || (MenuState & (MF_GRAYED | MF_DISABLED)) || (GetClassLongPtrW(pcontext->hWnd, GCL_STYLE) & CS_NOCLOSE)) { iStateId = (pcontext->Active ? BUTTON_DISABLED : BUTTON_INACTIVE_DISABLED); } diff --git a/win32ss/user/ntuser/defwnd.c b/win32ss/user/ntuser/defwnd.c index a9f4aa0bb34..e2fb6836c23 100644 --- a/win32ss/user/ntuser/defwnd.c +++ b/win32ss/user/ntuser/defwnd.c @@ -920,7 +920,7 @@ IntDefWindowProc( if (wParam == VK_F4) /* Try to close the window */ { PWND top = UserGetAncestor(Wnd, GA_ROOT); - if (!(top->style & CS_NOCLOSE)) + if (!(top->pcls->style & CS_NOCLOSE)) UserPostMessage(UserHMGetHandle(top), WM_SYSCOMMAND, SC_CLOSE, 0); } else if (wParam == VK_SNAPSHOT) // Alt-VK_SNAPSHOT?