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". After0aa7588only 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) <noreply@anthropic.com>
This commit is contained in:
@@ -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<LPNMHEADER>(pNMHDR);
|
||||
int nColumn = pNMHeader->iItem; // 获取点击的列索引
|
||||
SortByColumn(nColumn); // 调用排序函数
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
// 虚拟列表数据回调 - 当列表需要显示某行某列的数据时调用
|
||||
|
||||
Reference in New Issue
Block a user