Process HDN_ITEMCHANGING notifications only when column is being resized

When column resizing is finished, after HDN_ENDTRACK notification there is
also sent one (and last) HDN_ITEMCHANGING notification. We have to skip it
to prevent from sending EVT_HEADER_RESIZING after EVT_HEADER_END_RESIZE
because EVT_HEADER_END_RESIZE should be really the last one event
in the sequence of resizing events (like it's assumed in wxGrid).

Closes #16390.
This commit is contained in:
Artur Wieczorek 2017-11-20 21:32:08 +01:00
parent 8f9c4470d7
commit 1033a1636d
2 changed files with 33 additions and 2 deletions

View File

@ -139,6 +139,9 @@ private:
// actual column we are dragging or -1 if not dragging anything
int m_colBeingDragged;
// a column is currently being resized
bool m_isColBeingResized;
// the custom draw helper: initially NULL, created on demand, use
// GetCustomDraw() to do it
wxMSWHeaderCtrlCustomDraw *m_customDraw;

View File

@ -95,6 +95,7 @@ void wxHeaderCtrl::Init()
m_imageList = NULL;
m_scrollOffset = 0;
m_colBeingDragged = -1;
m_isColBeingResized = false;
m_customDraw = NULL;
}
@ -695,8 +696,9 @@ bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
break;
}
m_isColBeingResized = true;
evtType = wxEVT_HEADER_BEGIN_RESIZE;
// fall through
wxFALLTHROUGH;
case HDN_ENDTRACKA:
case HDN_ENDTRACKW:
@ -710,6 +712,8 @@ bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
const int minWidth = GetColumn(idx).GetMinWidth();
if ( width < minWidth )
width = minWidth;
m_isColBeingResized = false;
}
break;
@ -719,7 +723,31 @@ bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
// just in case we are dealing with one of these buggy versions.
case HDN_TRACK:
case HDN_ITEMCHANGING:
if ( nmhdr->pitem && (nmhdr->pitem->mask & HDI_WIDTH) )
// With "Show window contents while dragging" option enabled
// the sequence of notifications is as follows:
// HDN_BEGINTRACK
// HDN_ITEMCHANGING
// HDN_ITEMCHANGED
// ...
// HDN_ITEMCHANGING
// HDN_ITEMCHANGED
// HDN_ENDTRACK
// HDN_ITEMCHANGING
// HDN_ITEMCHANGED
// With "Show window contents while dragging" option disabled
// the sequence looks in turn like this:
// HDN_BEGINTRACK
// HDN_ITEMTRACK
// HDN_ITEMCHANGING
// ...
// HDN_ITEMTRACK
// HDN_ITEMCHANGING
// HDN_ENDTRACK
// HDN_ITEMCHANGING
// HDN_ITEMCHANGED
// In both cases last HDN_ITEMCHANGING notification is sent
// after HDN_ENDTRACK so we have to skip it.
if ( nmhdr->pitem && (nmhdr->pitem->mask & HDI_WIDTH) && m_isColBeingResized )
{
// prevent the column from being shrunk beneath its min width
width = nmhdr->pitem->cxy;