From 70a6b0128ee031c1ae2adfde0448dcc6d07d7be4 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Thu, 7 May 2026 10:47:05 +0200 Subject: [PATCH] Fix: log list header click was sorting host list (longstanding cross-talk) ON_NOTIFY(HDN_ITEMCLICK, 0, ...) matches the inner header control's ID, which is 0 for both m_CList_Online and m_CList_Message. So clicks on either list's header reach OnHdnItemclickList, which always sorts the host list by the clicked column index. The cross-talk has existed since the initial migration commit (5a325a2). It went unnoticed because pre-0aa7588 both lists' headers triggered the handler in A mode and the columns happened to align (host list cols 0..2 == IP/Addr/Location, log list also has 3 cols), so log-header clicks appeared to "sort plausibly". After 0aa7588 only the log list's A-mode header reached the handler, surfacing the strange "click log header re-sorts hosts" behavior. Guard the handler by checking pNMHDR->hwndFrom against the online list's header HWND. Log header clicks now have no effect on the host list. Co-Authored-By: Claude Opus 4.7 (1M context) --- server/2015Remote/2015RemoteDlg.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index 438e9e2..4906e90 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -3489,10 +3489,17 @@ void CMy2015RemoteDlg::SortByColumn(int nColumn) void CMy2015RemoteDlg::OnHdnItemclickList(NMHDR* pNMHDR, LRESULT* pResult) { + *pResult = 0; + // ON_NOTIFY(HDN_ITEMCLICK, 0, ...) 的 ID=0 匹配的是 listview 内部 header 控件 ID, + // 而 m_CList_Online 和 m_CList_Message 的 header 内部 ID 都是 0,导致两边表头点击 + // 都进这个回调(老 bug)。只处理在线主机列表的 header,避免点日志列表表头串到主机排序。 + HWND hOnlineHeader = ListView_GetHeader(m_CList_Online.GetSafeHwnd()); + if (pNMHDR->hwndFrom != hOnlineHeader) { + return; + } LPNMHEADER pNMHeader = reinterpret_cast(pNMHDR); int nColumn = pNMHeader->iItem; // 获取点击的列索引 SortByColumn(nColumn); // 调用排序函数 - *pResult = 0; } // 虚拟列表数据回调 - 当列表需要显示某行某列的数据时调用