Add warning message on "Read-only attribute in Windows" command failure

Follow e38016e3f5
This commit is contained in:
Don Ho 2025-06-24 16:02:51 +02:00
parent e38016e3f5
commit f0f8f7ec2f
6 changed files with 27 additions and 4 deletions

View File

@ -1601,6 +1601,7 @@ If you require the backward regex searching feature, consult the user manual for
<FindAutoChangeOfInSelectionWarning title="Search warning" message="The &quot;In selection&quot; checkbox state has been automatically modified.
Please verify the search condition before performing the action."/> <!-- HowToReproduce: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14897#issuecomment-2564316224 -->
<Need2Restart2ShowMenuShortcuts title="Notepad++ needs to be restarted" message="Notepad++ needs to be restarted to show right menu shortcuts."/>
<NoAdminRight2ChangeReadOnlyFileAttribute title="Changing file read-only attributes failed" message="Please run Notepad++ as administrator to change the file attributes."/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="Clipboard History"/>

View File

@ -1601,6 +1601,7 @@ If you require the backward regex searching feature, consult the user manual for
<FindAutoChangeOfInSelectionWarning title="Search warning" message="The &quot;In selection&quot; checkbox state has been automatically modified.
Please verify the search condition before performing the action."/> <!-- HowToReproduce: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14897#issuecomment-2564316224 -->
<Need2Restart2ShowMenuShortcuts title="Notepad++ needs to be restarted" message="Notepad++ needs to be restarted to show right menu shortcuts."/>
<NoAdminRight2ChangeReadOnlyFileAttribute title="Changing file read-only attributes failed" message="Please run Notepad++ as administrator to change the file attributes."/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="Clipboard History"/>

View File

@ -1596,6 +1596,7 @@ Si vous avez besoin de la fonction de recherche dexpression régulière inver
<FindAutoChangeOfInSelectionWarning title="Avertissement de recherche" message="L'état de laa case à cocher &quot;Dans la sélection&quot; a été automatiquement modifié.
Veuillez vérifier la condition de recherche avant de procéder à l'action."/> <!-- HowToReproduce: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14897#issuecomment-2564316224 -->
<Need2Restart2ShowMenuShortcuts title="Redémarrer Notepad++" message="Vous avez besoins de redémarrer Notepad++ afin d'afficher menu ▼ ✕ "/>
<NoAdminRight2ChangeReadOnlyFileAttribute title="Impossible de modifier l'attribut lecture seule" message="Veuillez lancer Notepad++ en mode « Administrateur » pour modifier cet attribut du fichier."/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="Historique du presse-papier"/>

View File

@ -408,8 +408,8 @@
<Item CMDID="41016" name="移至回收筒"/>
<Item CMDID="41014" name="重新載入"/>
<Item CMDID="41010" name="列印"/>
<Item CMDID="42028" name="唯讀"/>
<Item CMDID="42033" name="取消唯讀"/>
<Item CMDID="42028" name="在 Notepad++ 中設為唯讀"/>
<Item CMDID="42033" name="檔案系統權限唯讀"/>
<Item CMDID="2" name="複製到剪貼簿"/>
<Item CMDID="42029" name="複製完整路徑檔名"/>
<Item CMDID="42030" name="複製檔名"/>
@ -1470,6 +1470,7 @@
<RTLvsDirectWrite title="無法執行「文字由右至左」指令" message="「文字由右至左」指令與「直接寫入」模式不相容。 請在偏好設定對話框的「其他」中停用「直接寫入」模式,然後重新​​啟動 Notepad++ 。"/>
<FileMemoryAllocationFailed title="例外狀況:檔案記憶體分配失敗" message="可能沒有足夠的連續可用記憶體供 Notepad++ 載入檔案。"/>
<Need2Restart2ShowMenuShortcuts title="重新啟動 Notepad++" message="Notepad++ 需要重新啟動才能顯示選單右邊捷徑。"/>
<NoAdminRight2ChangeReadOnlyFileAttribute title="更改檔案維讀屬性失敗" message="請在系統管理員模式下重新啟動 Notepad++ 以使用此功能。"/>
</MessageBox>
<ClipboardHistory>
<PanelTitle name="剪貼簿記錄"/>

View File

@ -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;

View File

@ -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