Feature: Add a "Copy Name" item to the online host context menu

The online list already lets an operator copy everything about a host
through "Copy Client Info", but there was no quick way to grab just the
names, which is what people actually paste into a chat or a ticket. The
new menu item sits directly below "Edit Group" and copies the names of
all selected hosts to the clipboard, separated by semicolons.

"Name" means what the first column of the list shows: the remark when one
has been set, otherwise the computer name. The column text is CP_ACP, so
the handler decodes it the same way OnGetdispinfo does; that keeps the
copied text identical to what is on screen, including for Chinese remarks.
Clipboard writing reuses the existing UTF-8 based SetClipboardText helper
instead of growing a third copy of the same CF_UNICODETEXT code.

The item also gets its own 16x16 icon (two stacked cards with text bars,
drawn on the usual 240,240,240 background) loaded into a newly added
m_bmOnline[75] slot, and translations were added for English, German and
Traditional Chinese so the item does not fall back to simplified Chinese
when another UI language is active. The user manual and the resource
README were updated to match.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-10-29 22:06:33 +01:00
1 parent dcb5ae25c6
commit 1d875ddbd1
10 files changed
+49 -3

No files matched your search

+38
View File
@@ -746,6 +746,7 @@ CMy2015RemoteDlg::CMy2015RemoteDlg(CWnd* pParent): CDialogLangEx(CMy2015RemoteDl
m_bmOnline[72].LoadBitmap(IDB_BITMAP_PREVIEW_QUALITY); // 高级→屏幕预览质量等级
m_bmOnline[73].LoadBitmap(IDB_BITMAP_FILE_SPEED); // 高级→文件传输速度
m_bmOnline[74].LoadBitmap(IDB_BITMAP_DISCLAIMER); // 其他→免责声明
m_bmOnline[75].LoadBitmap(IDB_BITMAP_COPYNAME); // 右键→复制名称
for (int i = 0; i < PAYLOAD_MAXTYPE; i++) {
m_ServerDLL[i] = nullptr;
m_ServerBin[i] = nullptr;
@@ -1122,6 +1123,7 @@ BEGIN_MESSAGE_MAP(CMy2015RemoteDlg, CDialogEx)
ON_MESSAGE(WM_SPLITTER_MOVED, &CMy2015RemoteDlg::OnSplitterMoved)
ON_MESSAGE(WM_SPLITTER_RELEASED, &CMy2015RemoteDlg::OnSplitterReleased)
ON_COMMAND(ID_COPY_CLIENT_INFO, &CMy2015RemoteDlg::OnCopyClientInfo)
ON_COMMAND(ID_ONLINE_COPY_NAME, &CMy2015RemoteDlg::OnOnlineCopyName)
ON_COMMAND(ID_ONLINE_ACTIVE_WND, &CMy2015RemoteDlg::OnOnlineActiveWnd)
ON_COMMAND(ID_ONLINE_VIEW_WND, &CMy2015RemoteDlg::OnOnlineWindowManager)
ON_COMMAND(ID_ENABLE_DEV_DEBUG, &CMy2015RemoteDlg::OnEnableDevDebug)
@@ -4596,6 +4598,7 @@ void CMy2015RemoteDlg::OnNMRClickOnline(NMHDR *pNMHDR, LRESULT *pResult)
Menu.SetMenuItemBitmaps(ID_ONLINE_UNINSTALL, MF_BYCOMMAND, &m_bmOnline[15], &m_bmOnline[15]);
Menu.SetMenuItemBitmaps(ID_ONLINE_PRIVATE_SCREEN, MF_BYCOMMAND, &m_bmOnline[16], &m_bmOnline[16]);
Menu.SetMenuItemBitmaps(ID_ONLINE_REGROUP, MF_BYCOMMAND, &m_bmOnline[17], &m_bmOnline[17]);
Menu.SetMenuItemBitmaps(ID_ONLINE_COPY_NAME, MF_BYCOMMAND, &m_bmOnline[75], &m_bmOnline[75]);
Menu.SetMenuItemBitmaps(ID_ONLINE_INJ_NOTEPAD, MF_BYCOMMAND, &m_bmOnline[18], &m_bmOnline[18]);
Menu.SetMenuItemBitmaps(ID_PROXY_PORT, MF_BYCOMMAND, &m_bmOnline[19], &m_bmOnline[19]);
// Session management icons (shutdown/reboot/logout)
@@ -13474,6 +13477,41 @@ void CMy2015RemoteDlg::OnCopyClientInfo()
CloseClipboard();
}
// 右键→复制名称:把选中主机的名称写进剪贴板(多选用分号连接)。
// "名称"就是列表第一列显示的内容——有备注取备注,否则取计算机名;列数据是 CP_ACP
// 的 CString,和 OnGetdispinfo 用同一套解码方式,保证复制到的文字与屏幕一致。
void CMy2015RemoteDlg::OnOnlineCopyName()
{
std::wstring names;
EnterCriticalSection(&m_cs);
int nItem = m_CList_Online.GetNextItem(-1, LVNI_SELECTED);
while (nItem != -1) {
context* ctx = GetContextByListIndex(nItem);
if (ctx) {
CString note = m_ClientMap->GetClientMapData(ctx->GetClientID(), MAP_NOTE);
CString text = !note.IsEmpty() ? note : ctx->GetClientData(ONLINELIST_COMPUTER_NAME);
int wlen = text.IsEmpty() ? 0 : MultiByteToWideChar(CP_ACP, 0, text, -1, NULL, 0);
if (wlen > 1) {
std::wstring w(wlen - 1, L'\0');
MultiByteToWideChar(CP_ACP, 0, text, -1, &w[0], wlen);
if (!names.empty()) names += L';';
names += w;
}
}
nItem = m_CList_Online.GetNextItem(nItem, LVNI_SELECTED);
}
LeaveCriticalSection(&m_cs);
if (names.empty()) return;
// 复用本文件已有的 UTF-8 版剪贴板写入,不再造第三份 CF_UNICODETEXT 代码
int len = WideCharToMultiByte(CP_UTF8, 0, names.c_str(), (int)names.size(), NULL, 0, NULL, NULL);
if (len <= 0) return;
std::string utf8(len, '\0');
WideCharToMultiByte(CP_UTF8, 0, names.c_str(), (int)names.size(), &utf8[0], len, NULL, NULL);
SetClipboardText(utf8.c_str());
}
void CMy2015RemoteDlg::OnOnlineActiveWnd()
{
POSITION Pos = m_CList_Online.GetFirstSelectedItemPosition();