From 7cc002680a012d8fa0fa6f3f829d154ea05693da Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 13 Jun 2025 19:19:33 +0200 Subject: [PATCH] Fix right click on caption bar unhidding main menu Fix #16652, close #16682 --- PowerEditor/src/NppBigSwitch.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index d177ea322..4a6290720 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -2969,7 +2969,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa ((toTray == sta_close || toTray == sta_minimize_close) && wParam == SC_CLOSE) ) { - if (nullptr == _pTrayIco) + if (!_pTrayIco) { HICON icon = nullptr; Notepad_plus_Window::loadTrayIcon(_pPublicInterface->getHinst(), &icon); @@ -2983,11 +2983,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } - if (wParam == SC_KEYMENU && lParam == VK_SPACE) + if ((wParam & 0xFFF0) == SC_KEYMENU && lParam == VK_SPACE) // typing Alt-Space to have the system menu of application icon in the title bar { _sysMenuEntering = true; } - else if (wParam == 0xF093) //it should be SC_MOUSEMENU. A bug? + else if ((wParam & 0xFFF0) == SC_MOUSEMENU) // clicking the application icon in the title bar to have the system menu { _sysMenuEntering = true; } @@ -2995,6 +2995,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return ::DefWindowProc(hwnd, message, wParam, lParam); } + case WM_NCRBUTTONDOWN: // right click on the title bar to have system menu (in the form of contextual menu beside of mouse cursor) + { + if (wParam == HTCAPTION) + { + _sysMenuEntering = true; + } + return ::DefWindowProc(hwnd, message, wParam, lParam); + } + case WM_LBUTTONDBLCLK: { ::SendMessage(hwnd, WM_COMMAND, IDM_FILE_NEW, 0);