From 3921812175b7c537106af934ba4b9cbd4350c89f Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 14 Jan 2025 11:19:07 +0100 Subject: [PATCH] GUI enhancement: hide right menu shorcuts on the fly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the option "Hide right shortcuts + ▼ ✕" (in Preferences->General->Menu) hide right menu shortcuts immediately. --- PowerEditor/installer/nativeLang/english.xml | 9 ++--- .../nativeLang/english_customizable.xml | 36 ++++++++++--------- PowerEditor/installer/nativeLang/french.xml | 3 +- .../nativeLang/taiwaneseMandarin.xml | 3 +- PowerEditor/src/Notepad_plus.cpp | 18 +--------- PowerEditor/src/NppBigSwitch.cpp | 24 +++++++++++++ PowerEditor/src/NppCommands.cpp | 2 +- .../WinControls/Preference/preferenceDlg.cpp | 20 +++++++++-- PowerEditor/src/resource.h | 1 + 9 files changed, 74 insertions(+), 42 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index c032d5680..8fc38ed0a 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -972,8 +972,8 @@ Translation note: - - + + @@ -1525,8 +1525,8 @@ Do you want to launch Notepad++ in Administrator mode?"/> - - + + + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 2fe9a2336..95da7dc32 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -356,7 +356,7 @@ Translation note: - + @@ -412,8 +412,8 @@ Translation note: - - + + @@ -750,14 +750,14 @@ Translation note: - - - - - - - - + + + + + + + + @@ -961,6 +961,7 @@ Translation note: + @@ -971,8 +972,8 @@ Translation note: - - + + @@ -1101,6 +1102,7 @@ Translation note: + @@ -1523,8 +1525,8 @@ Do you want to launch Notepad++ in Administrator mode?"/> - - + + + @@ -1691,7 +1694,7 @@ Find in all files but exclude folders tests, bin && bin64: Find in all files but exclude all folders log or logs recursively: *.* !+\log*"/> - + @@ -1827,6 +1830,7 @@ Click on "?" button on right to open website with User Manual."/> C, C++, Java, C#, Objective-C, PHP, JavaScript, JSP, CSS, Perl, Rust, PowerShell and JSON. If you select advanced mode but do not edit files in the aforementioned languages, the indentation will remain in basic mode."/> + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 7089ab2db..732fa86d2 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -972,7 +972,7 @@ Translation note: - + @@ -1549,6 +1549,7 @@ REMARQUE : Si vous choisissez de ne pas créer d’espaces réservés ou de les Appuyez sur le bouton OK pour ouvrir la boîte de dialogue de recherche ou lui donner la priorité. Si vous avez besoin de la fonction de recherche d’expression régulière inversée, consultez le manuel de l’utilisateur pour savoir comment l’activer."/> + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index 339c78462..9797eb9bf 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -927,7 +927,7 @@ - + @@ -1428,6 +1428,7 @@ 請注意,如果你選擇不創建佔位欄或稍後關閉它們,工作階段檔案將在 Notepad++ 關閉時被修改。我們建議你現在備份工作階段檔案 "session.xml" 。"/> + diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index b4d9a85dd..38cd89afd 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -791,23 +791,7 @@ LRESULT Notepad_plus::init(HWND hwnd) //Hide or show the right shortcuts "+" "▼" "✕" of main menu bar if (nppGUI._hideMenuRightShortcuts) { - int nbRemoved = 0; - const int bufferSize = 64; - wchar_t buffer[bufferSize]; - int nbItem = GetMenuItemCount(_mainMenuHandle); - for (int i = nbItem - 1; i >= 0; --i) - { - ::GetMenuStringW(_mainMenuHandle, i, buffer, bufferSize, MF_BYPOSITION); - if (lstrcmp(buffer, L"✕") == 0 || lstrcmp(buffer, L"▼") == 0 || lstrcmp(buffer, L"+") == 0) - { - ::RemoveMenu(_mainMenuHandle, i, MF_BYPOSITION); - ++nbRemoved; - } - if (nbRemoved == 3) - break; - } - if (nbRemoved > 0) - ::DrawMenuBar(hwnd); + ::SendMessage(_pPublicInterface->getHSelf(), NPPM_INTERNAL_HIDEMENURIGHTSHORTCUTS, 0, 0); } // diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 5fe414fd3..ac7712f07 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -4100,6 +4100,30 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } + case NPPM_INTERNAL_HIDEMENURIGHTSHORTCUTS: + { + if (nppParam.getNppGUI()._hideMenuRightShortcuts) + { + int nbRemoved = 0; + const int bufferSize = 64; + wchar_t buffer[bufferSize]; + int nbItem = GetMenuItemCount(_mainMenuHandle); + for (int i = nbItem - 1; i >= 0; --i) + { + ::GetMenuStringW(_mainMenuHandle, i, buffer, bufferSize, MF_BYPOSITION); + if (lstrcmp(buffer, L"✕") == 0 || lstrcmp(buffer, L"▼") == 0 || lstrcmp(buffer, L"+") == 0) + { + ::RemoveMenu(_mainMenuHandle, i, MF_BYPOSITION); + ++nbRemoved; + } + if (nbRemoved == 3) + break; + } + if (nbRemoved > 0) + ::DrawMenuBar(hwnd); + } + return TRUE; + } default: { diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index c3dea4dec..e90622722 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -3117,7 +3117,7 @@ void Notepad_plus::command(int id) pNativeSpeaker->messageBox("NeedToRestartToLoadPlugins", _pPublicInterface->getHSelf(), L"You have to restart Notepad++ to load plugins you installed.", - L"Notepad++ need to be relaunched", + L"Notepad++ needs to be relaunched", MB_OK | MB_APPLMODAL); } break; diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index ba6fc0e45..93f8f0bfe 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -701,6 +701,22 @@ intptr_t CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM bool isChecked = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_HIDERIGHTSHORTCUTSOFMENUBAR, BM_GETCHECK, 0, 0)); NppGUI& nppGUI = nppParam.getNppGUI(); nppGUI._hideMenuRightShortcuts = isChecked; + static bool isFirstShow = true; + if (isChecked) + { + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_HIDEMENURIGHTSHORTCUTS, 0, isChecked ? TRUE : FALSE); + } + else if (isFirstShow) + { + NativeLangSpeaker* pNativeSpeaker = nppParam.getNativeLangSpeaker(); + pNativeSpeaker->messageBox("Need2Restart2ShowMenuShortcuts", + _hSelf, + L"Notepad++ needs to be restarted to show right menu shorcuts.", + L"Notepad++ need to be restarted", + MB_OK | MB_APPLMODAL); + + isFirstShow = false; + } } return TRUE; @@ -2300,7 +2316,7 @@ intptr_t CALLBACK MarginsBorderEdgeSubDlg::run_dlgProc(UINT message, WPARAM wPar pNativeSpeaker->messageBox("ChangeHistoryEnabledWarning", _hSelf, L"You have to restart Notepad++ to enable Change History.", - L"Notepad++ need to be relaunched", + L"Notepad++ needs to be relaunched", MB_OK | MB_APPLMODAL); changeHistoryWarningHasBeenGiven = true; @@ -2332,7 +2348,7 @@ intptr_t CALLBACK MarginsBorderEdgeSubDlg::run_dlgProc(UINT message, WPARAM wPar pNativeSpeaker->messageBox("ChangeHistoryEnabledWarning", _hSelf, L"You have to restart Notepad++ to enable Change History.", - L"Notepad++ need to be relaunched", + L"Notepad++ needs to be relaunched", MB_OK | MB_APPLMODAL); changeHistoryWarningHasBeenGiven = true; diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index c78409321..2b12409e5 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -743,6 +743,7 @@ #define NPPM_INTERNAL_LWALIGN (NOTEPADPLUS_USER_INTERNAL + 104) #define NPPM_INTERNAL_LWINDENT (NOTEPADPLUS_USER_INTERNAL + 105) #define NPPM_INTERNAL_CHECKDOCSTATUS (NOTEPADPLUS_USER_INTERNAL + 106) + #define NPPM_INTERNAL_HIDEMENURIGHTSHORTCUTS (NOTEPADPLUS_USER_INTERNAL + 187)