From da0ec983baf0f036dbcfbbb5416ce6370bf50b55 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Thu, 8 Oct 2026 22:15:31 +0200 Subject: [PATCH] Feature: Show live transfer speed in file-transfer dialog title MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a smoothed bytes-per-second readout to the CDlgFileSend title, refreshed about every 200 ms during transfer (e.g. "å�‘é€�文件 - 5.3M/s"). The base title is captured on the first progress frame and the speed suffix applied through Unicode APIs (GetWindowTextW / SetWindowTextW), so the whole title stays correct on non-Chinese systems where the ANSI message path would misdecode GBK as the system ACP. Also add the missing "接收文件 (V2)" translation (en_US "Receive File (V2)", zh_TW "接收檔案 (V2)"), so the V2 receive title no longer falls back to raw Chinese on non-Chinese systems. Co-Authored-By: deepseek-v4-pro --- server/2015Remote/CDlgFileSend.cpp | 49 ++++++++++++++++++++++++++++++ server/2015Remote/CDlgFileSend.h | 10 ++++++ server/2015Remote/lang/en_US.ini | 1 + server/2015Remote/lang/zh_TW.ini | 1 + 4 files changed, 61 insertions(+) diff --git a/server/2015Remote/CDlgFileSend.cpp b/server/2015Remote/CDlgFileSend.cpp index 4ac6469..f078752 100644 --- a/server/2015Remote/CDlgFileSend.cpp +++ b/server/2015Remote/CDlgFileSend.cpp @@ -151,6 +151,54 @@ void CDlgFileSend::UpdateProgress(CString file, const FileProgressInfo& info) PostMessageA(WM_UPDATEFILEPROGRESS, (WPARAM)new CString(file), (LPARAM)new FileProgressInfo(info)); } +// 将字节/ç§’æ ¼å¼�化为人类å�¯è¯»çš„速度串(如 "5.3M/s"ã€�"320K/s"ã€�"800B/s") +static CStringW FormatSpeed(double bps) +{ + CStringW s; + if (bps >= 1024.0 * 1024.0) + s.Format(L"%.1fM/s", bps / (1024.0 * 1024.0)); + else if (bps >= 1024.0) + s.Format(L"%.0fK/s", bps / 1024.0); + else + s.Format(L"%.0fB/s", bps); + return s; +} + +// 累计字节并周期性刷新标题中的速度(如 "å�‘é€�文件 - 5.3M/s") +void CDlgFileSend::UpdateTitleWithSpeed(uint64_t dataLength) +{ + m_ullTotalBytes += dataLength; + ULONGLONG now = GetTickCount64(); + + // 首帧:用 Unicode API æ�•获当å‰�标题作为基础部分(å�¯èƒ½å·²è¢« V2/C2C 覆盖为 "接收文件 (V2)" 等), + // 并建立采样基准;此时尚无速度å�¯æ˜¾ç¤ºã€‚ + if (!m_bBaseTitleCaptured) { + WCHAR wBase[128] = { 0 }; + ::GetWindowTextW(m_hWnd, wBase, 128); + m_strBaseTitle = wBase; + m_bBaseTitleCaptured = true; + m_ullLastTick = now; + m_ullLastBytes = m_ullTotalBytes; + return; + } + + ULONGLONG dt = now - m_ullLastTick; + if (dt < 200) return; // 采样间隔未到,仅累积字节 + + uint64_t delta = m_ullTotalBytes - m_ullLastBytes; + double speed = dt ? (double)delta * 1000.0 / (double)dt : 0.0; + m_dSpeedBps = (m_dSpeedBps == 0.0) ? speed : m_dSpeedBps * 0.6 + speed * 0.4; // 轻度平滑 + + m_ullLastTick = now; + m_ullLastBytes = m_ullTotalBytes; + + // 基础标题(Unicode)+ ASCII 速度å�Žç¼€ï¼Œå…¨ç¨‹ Unicode API,é�¿å…�é�žä¸­æ–‡ç³»ç»Ÿä¸Š ANSI 消æ�¯æŒ‰ç³»ç»Ÿ ACP è§£ç �ä¹±ç � + CStringW title = m_strBaseTitle; + title += L" - "; + title += FormatSpeed(m_dSpeedBps); + ::SetWindowTextW(m_hWnd, title); +} + void CDlgFileSend::FinishFileSend(BOOL succeed) { if (!GetSafeHwnd()) return; @@ -170,6 +218,7 @@ LRESULT CDlgFileSend::OnUpdateFileProgress(WPARAM wParam, LPARAM lParam) SetDlgItemText(IDC_STATIC_CURRENTINDEX, status); SetDlgItemText(IDC_STATIC_CURRENT_FILE, *pFile); m_Progress.SetPos((int)percent); + UpdateTitleWithSpeed(pInfo->dataLength); // å�ªåœ¨ç¬¬ä¸€æ¬¡æ˜¾ç¤ºæ—¶ç½®é¡¶ï¼Œå�Žç»­æ›´æ–°ä¸�抢焦点 if (!IsWindowVisible()) { diff --git a/server/2015Remote/CDlgFileSend.h b/server/2015Remote/CDlgFileSend.h index 6e243c5..65c04af 100644 --- a/server/2015Remote/CDlgFileSend.h +++ b/server/2015Remote/CDlgFileSend.h @@ -51,6 +51,14 @@ public: BOOL m_bTargetOffline = FALSE; // C2C目标已离线,已å�‘é€�å�–消包 enum { IDD = IDD_DIALOG_FILESEND }; + // 传输速度统计(用于标题实时显示速度,如 "å�‘é€�文件 - 5.3M/s") + CStringW m_strBaseTitle; // 标题基础部分("å�‘é€�文件"/"接收文件 (V2)" 等,Unicode),首帧进度时æ�•获 + bool m_bBaseTitleCaptured = false; + uint64_t m_ullTotalBytes = 0; // 累计传输字节 + uint64_t m_ullLastBytes = 0; + ULONGLONG m_ullLastTick = 0; // 上次速度采样时刻 (ms) + double m_dSpeedBps = 0.0; // 平滑å�Žçš„速度 (B/s) + protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支æŒ� @@ -59,6 +67,8 @@ protected: afx_msg LRESULT OnUpdateFileProgress(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnFinishFileSend(WPARAM wParam, LPARAM lParam); + void UpdateTitleWithSpeed(uint64_t dataLength); // 累计字节并周期性刷新标题速度 + public: CProgressCtrl m_Progress; virtual BOOL OnInitDialog(); diff --git a/server/2015Remote/lang/en_US.ini b/server/2015Remote/lang/en_US.ini index 9ace1b5..f0836e3 100644 --- a/server/2015Remote/lang/en_US.ini +++ b/server/2015Remote/lang/en_US.ini @@ -1400,6 +1400,7 @@ RDP C2C Îļþ´«Êä=C2C File Transfer Ðø´«Îļþ (V2)=Resume File Upload (V2) ·¢ËÍÎļþ (V2)=Send File (V2) +½ÓÊÕÎļþ (V2)=Receive File (V2) ·¢ËÍÎļþ(%d/%d): %.2f%%=Send Files(%d/%d): %.2f%% ½ÓÊÕÎļþ(%d/%d): %.2f%%=Recv Files(%d/%d): %.2f%% [Ô¶³ÌÓÒ¼ü¸´ÖÆ, ±¾µØ Ctrl+V Õ³Ìù]= [Remote Right-click Copy, Local Ctrl+V Paste] diff --git a/server/2015Remote/lang/zh_TW.ini b/server/2015Remote/lang/zh_TW.ini index a453ab0..94a23d8 100644 --- a/server/2015Remote/lang/zh_TW.ini +++ b/server/2015Remote/lang/zh_TW.ini @@ -1396,6 +1396,7 @@ RDP C2C Îļþ´«Êä=C2C ™n°¸‚÷Ý” Ðø´«Îļþ (V2)=Àm‚÷™n°¸ (V2) ·¢ËÍÎļþ (V2)=‚÷ËÍ™n°¸ (V2) +½ÓÊÕÎļþ (V2)=½ÓÊÕ™n°¸ (V2) ·¢ËÍÎļþ(%d/%d): %.2f%%=·¢ËÍÎļþ(%d/%d): %.2f%% ½ÓÊÕÎļþ(%d/%d): %.2f%%=½ÓÊÕÎļþ(%d/%d): %.2f%% [Ô¶³ÌÓÒ¼ü¸´ÖÆ, ±¾µØ Ctrl+V Õ³Ìù]= [ßh¶ËÓÒæIÑ}Ñu, ±¾µØ Ctrl+V ÙNÉÏ]