From f0f8f7ec2f5d95a019e9ee20edae2e7465ea5719 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 24 Jun 2025 16:02:51 +0200 Subject: [PATCH] Add warning message on "Read-only attribute in Windows" command failure Follow https://github.com/notepad-plus-plus/notepad-plus-plus/commit/e38016e3f52e49eaf22974008e46f98fc85ef080 --- PowerEditor/installer/nativeLang/english.xml | 1 + .../nativeLang/english_customizable.xml | 1 + PowerEditor/installer/nativeLang/french.xml | 1 + .../nativeLang/taiwaneseMandarin.xml | 5 +++-- PowerEditor/src/NppCommands.cpp | 19 +++++++++++++++++++ .../src/WinControls/Preference/preference.rc | 4 ++-- 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 156c08854..b63adc626 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1601,6 +1601,7 @@ If you require the backward regex searching feature, consult the user manual for + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 07271a392..655b637a8 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -1601,6 +1601,7 @@ If you require the backward regex searching feature, consult the user manual for + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index dae9a6210..6e060fed0 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1596,6 +1596,7 @@ Si vous avez besoin de la fonction de recherche d’expression régulière inver + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index 798cb0eb3..291972749 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -408,8 +408,8 @@ - - + + @@ -1470,6 +1470,7 @@ + diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 5aaffe055..d03b44f9b 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -2110,7 +2110,26 @@ void Notepad_plus::command(int id) Buffer* buf = _pEditView->getCurrentBuffer(); bool isSysReadOnly = false; if (toggleReadOnlyFlagFromFileAttributes(buf->getFullPathName(), isSysReadOnly)) + { buf->setFileReadOnly(isSysReadOnly); + } + else + { + if (_isAdministrator) + { + MessageBox(_pPublicInterface->getHSelf(), GetLastErrorAsString(GetLastError()).c_str(), L"Changing file read-only attributes failed", MB_OK | MB_ICONWARNING); + } + else + { + // Not in admin mode, and file might be protected. So we can't change the file attributes. + _nativeLangSpeaker.messageBox("NoAdminRight2ChangeReadOnlyFileAttribute", + _pPublicInterface->getHSelf(), + L"Please run Notepad++ as administrator to change the file attributes.", + L"Changing file read-only attributes failed", + MB_OK | MB_ICONWARNING); + } + + } } break; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 175415cd8..573b308e6 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -264,8 +264,8 @@ BEGIN COMBOBOX IDC_COMBO_OTHERCP,257,125,100,140,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP RTEXT "Default language:",IDC_DEFAULTLANG_STATIC,16,125,77,8 COMBOBOX IDC_COMBO_DEFAULTLANG,98,123,100,140,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - CONTROL "Always open a new document in addition at startup",IDC_CHECK_ADDNEWDOCONSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,152,250,10 - CONTROL "Use the first line of document as untitled tab name",IDC_CHECK_USECONTENTASTABNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,165,250,10 + CONTROL "Always open a new document in addition at startup",IDC_CHECK_ADDNEWDOCONSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,152,270,10 + CONTROL "Use the first line of document as untitled tab name",IDC_CHECK_USECONTENTASTABNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,165,270,10 END