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:
@@ -139,6 +139,9 @@ private:
|
|||||||
// actual column we are dragging or -1 if not dragging anything
|
// actual column we are dragging or -1 if not dragging anything
|
||||||
int m_colBeingDragged;
|
int m_colBeingDragged;
|
||||||
|
|
||||||
|
// a column is currently being resized
|
||||||
|
bool m_isColBeingResized;
|
||||||
|
|
||||||
// the custom draw helper: initially NULL, created on demand, use
|
// the custom draw helper: initially NULL, created on demand, use
|
||||||
// GetCustomDraw() to do it
|
// GetCustomDraw() to do it
|
||||||
wxMSWHeaderCtrlCustomDraw *m_customDraw;
|
wxMSWHeaderCtrlCustomDraw *m_customDraw;
|
||||||
|
@@ -95,6 +95,7 @@ void wxHeaderCtrl::Init()
|
|||||||
m_imageList = NULL;
|
m_imageList = NULL;
|
||||||
m_scrollOffset = 0;
|
m_scrollOffset = 0;
|
||||||
m_colBeingDragged = -1;
|
m_colBeingDragged = -1;
|
||||||
|
m_isColBeingResized = false;
|
||||||
m_customDraw = NULL;
|
m_customDraw = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,8 +696,9 @@ bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_isColBeingResized = true;
|
||||||
evtType = wxEVT_HEADER_BEGIN_RESIZE;
|
evtType = wxEVT_HEADER_BEGIN_RESIZE;
|
||||||
// fall through
|
wxFALLTHROUGH;
|
||||||
|
|
||||||
case HDN_ENDTRACKA:
|
case HDN_ENDTRACKA:
|
||||||
case HDN_ENDTRACKW:
|
case HDN_ENDTRACKW:
|
||||||
@@ -710,6 +712,8 @@ bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
const int minWidth = GetColumn(idx).GetMinWidth();
|
const int minWidth = GetColumn(idx).GetMinWidth();
|
||||||
if ( width < minWidth )
|
if ( width < minWidth )
|
||||||
width = minWidth;
|
width = minWidth;
|
||||||
|
|
||||||
|
m_isColBeingResized = false;
|
||||||
}
|
}
|
||||||
break;
|
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.
|
// just in case we are dealing with one of these buggy versions.
|
||||||
case HDN_TRACK:
|
case HDN_TRACK:
|
||||||
case HDN_ITEMCHANGING:
|
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
|
// prevent the column from being shrunk beneath its min width
|
||||||
width = nmhdr->pitem->cxy;
|
width = nmhdr->pitem->cxy;
|
||||||
|
Reference in New Issue
Block a user