From c85039ea0a8b232fd0d7de0e63a61948946ab690 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Fri, 16 Oct 2026 13:03:05 +0200 Subject: [PATCH] Fix: Online-host list column-toggle leaves ghost artifact after last column CListCtrlEx::OnEraseBkgnd (with m_bSkipEraseBkgnd) only erases the empty area below the last item, not the horizontal strip right of the last column (the ~20px scrollbar reserve AdjustColumnWidths always leaves). Changing the column count via SetColumnVisible/ToggleColumnVisibility redistributed widths but never repainted with background erase, so stale pixels from the previous last column lingered next to the new one (e.g. after "TLS") until a tab switch or minimize/restore forced a full redraw. Mirror the proven OnSize needRefresh path: temporarily lift the skip-erase flag and issue a full RedrawWindow with RDW_ERASE|RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_UPDATENOW after each visibility change. Co-Authored-By: deepseek-v4-pro --- server/2015Remote/CListCtrlEx.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/2015Remote/CListCtrlEx.cpp b/server/2015Remote/CListCtrlEx.cpp index d2877e2..9065a48 100644 --- a/server/2015Remote/CListCtrlEx.cpp +++ b/server/2015Remote/CListCtrlEx.cpp @@ -160,6 +160,9 @@ void CListCtrlEx::SetColumnVisible(int nCol, BOOL bVisible) if (m_Columns[nCol].CanHide || bVisible) { // 不允许隐藏的列只能设为可见 m_Columns[nCol].Visible = bVisible; AdjustColumnWidths(); + // 列数变化后完整重绘(含背景擦除),否则最后一列右侧会残留旧列残影。 + ScopedEraseBkgnd scope(*this); + RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW); } } } @@ -230,6 +233,11 @@ void CListCtrlEx::ToggleColumnVisibility(int nColumn) // 重新调整列宽 AdjustColumnWidths(); + + // 列数变化后完整重绘(含背景擦除),否则最后一列(TLS 等)右侧会残留旧列残影。 + // 与 OnSize 中 needRefresh 分支相同的处理:临时放行背景擦除 + 全量 RedrawWindow。 + ScopedEraseBkgnd scope(*this); + RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW); } void CListCtrlEx::LoadColumnVisibility()