From 8d661b6bf8e2adc1a73fb2489f0689cdfaa52a66 Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Tue, 3 May 2016 21:55:55 +0400 Subject: [PATCH] Clarify and change a drawing fix for wxMSW ListCtrl with wxLC_VRULES Since 9eaba6927648cf2989a3fddf4a5e2deea1d62708 a fix was added for leaving behind trailing pixels when resizing a column in a ListCtrl that uses wxLC_VRULES. This fix is only needed for ComCtl32.dll versions prior to 6.0. Make the fix conditional and explain the (rare) conditions under which the problem still occurs. Also see #747. --- src/msw/listctrl.cpp | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index b699719fcc..b590ebce93 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -3098,16 +3098,42 @@ void wxListCtrl::OnPaint(wxPaintEvent& event) if (GetItemRect(itemCount - 1, itemRect)) { - // this is a fix for bug 673394: erase the pixels which we would - // otherwise leave on the screen - static const int gap = 2; - dc.SetPen(*wxTRANSPARENT_PEN); - dc.SetBrush(wxBrush(GetBackgroundColour())); - dc.DrawRectangle(0, firstItemRect.GetY() - gap, - clientSize.GetWidth(), gap); + /* + This is a fix for ticket #747: erase the pixels which we would + otherwise leave on the screen. - dc.SetPen(pen); - dc.SetBrush(*wxTRANSPARENT_BRUSH); + The drawing of the rectangle as a fix to erase trailing pixels + when resizing a column is only needed for ComCtl32 prior to + 6.0, i.e. when not using a manifest in which case 5.82 is + used. And even then it only happens when "Show window contents + while dragging" is enabled under Windows, resulting in live + updates when resizing columns. Note that even with that setting + on, at least under Windows 7 and 10 no live updating is done when + using ComCtl32 5.82. + + Revision b66c3a67519caa9debfd76e6d74954eaebfa56d9 made this fix + almost redundant, except that when you do NOT handle + EVT_LIST_COL_DRAGGING (or do and skip the event) the trailing + pixels still appear. In case of wanting to reproduce the problem + in the listctrl sample: comment out handling oF + EVT_LIST_COL_DRAGGING and also set useDrawFix to false and gap to + 2 (not 0). + */ + + static const bool useDrawFix = wxApp::GetComCtl32Version() < 600; + + static const int gap = useDrawFix ? 2 : 0; + + if (useDrawFix) + { + dc.SetPen(*wxTRANSPARENT_PEN); + dc.SetBrush(wxBrush(GetBackgroundColour())); + dc.DrawRectangle(0, firstItemRect.GetY() - gap, + clientSize.GetWidth(), gap); + + dc.SetPen(pen); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + } const int numCols = GetColumnCount(); wxVector indexArray(numCols);