From 8e170cf971eb119cca9f2af76da2ffe2e31dd71b Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Fri, 3 Jul 2026 20:57:54 +0200 Subject: [PATCH] Fix: toggle privacy wallpaper menu item to clear instead of re-picking when already set --- server/2015Remote/2015RemoteDlg.cpp | 65 ++++++++++++++++------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index d418342..2b887b9 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -10488,41 +10488,50 @@ void CMy2015RemoteDlg::OnParamEnableLog() void CMy2015RemoteDlg::OnParamPrivacyWallpaper() { + auto SubMenu = m_MainMenu.GetSubMenu(2); + + // 已设置壁纸:再次点击则清空 + if (!m_PrivateScreenWallpaper.IsEmpty()) { + m_PrivateScreenWallpaper.Empty(); + THIS_CFG.SetStr("settings", "Wallpaper", ""); + if (SubMenu) + SubMenu->CheckMenuItem(ID_PARAM_PRIVACY_WALLPAPER, MF_UNCHECKED); + return; + } + + // 未设置壁纸:弹出文件对话框 CFileDialog dlg(TRUE, _T("bmp"), NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, _T("BMP Files (*.bmp)|*.bmp|All Files (*.*)|*.*||"), this); - if (dlg.DoModal() == IDOK) { - CString path = dlg.GetPathName(); + if (dlg.DoModal() != IDOK) + return; - // 验证文件是否可以读取 - CFile file; - if (!file.Open(path, CFile::modeRead | CFile::typeBinary)) { - MessageBox(_TR("无法读取指定的BMP文件,请检查文件是否存在或权限是否正确。"), - _TR("错误"), MB_ICONERROR); - return; - } + CString path = dlg.GetPathName(); - // 验证是否是有效的BMP文件 - BITMAPFILEHEADER bmfh; - if (file.Read(&bmfh, sizeof(bmfh)) != sizeof(bmfh) || bmfh.bfType != 0x4D42) { - file.Close(); - MessageBox(_TR("指定的文件不是有效的BMP格式。"), - _TR("错误"), MB_ICONERROR); - return; - } - file.Close(); - - m_PrivateScreenWallpaper = path; - THIS_CFG.SetStr("settings", "Wallpaper", path.GetString()); - auto SubMenu = m_MainMenu.GetSubMenu(2); // 工具菜单 - if (SubMenu) { - SubMenu->CheckMenuItem(ID_PARAM_PRIVACY_WALLPAPER, MF_CHECKED); - } - CString msg; - msg.Format(_TR("隐私屏幕壁纸已设置为:\n%s"), path); - MessageBox(msg + CString("\n") + _L("如需恢复默认值,请从磁盘移除该文件。"), _TR("设置成功"), MB_ICONINFORMATION); + CFile file; + if (!file.Open(path, CFile::modeRead | CFile::typeBinary)) { + MessageBox(_TR("无法读取指定的BMP文件,请检查文件是否存在或权限是否正确。"), + _TR("错误"), MB_ICONERROR); + return; } + + BITMAPFILEHEADER bmfh; + if (file.Read(&bmfh, sizeof(bmfh)) != sizeof(bmfh) || bmfh.bfType != 0x4D42) { + file.Close(); + MessageBox(_TR("指定的文件不是有效的BMP格式。"), + _TR("错误"), MB_ICONERROR); + return; + } + file.Close(); + + m_PrivateScreenWallpaper = path; + THIS_CFG.SetStr("settings", "Wallpaper", path.GetString()); + if (SubMenu) + SubMenu->CheckMenuItem(ID_PARAM_PRIVACY_WALLPAPER, MF_CHECKED); + CString msg; + msg.Format(_TR("隐私屏幕壁纸已设置为:\n%s"), path); + MessageBox(msg, _TR("设置成功"), MB_ICONINFORMATION); } void CMy2015RemoteDlg::OnParamFileV2()