m_numColumns = 0;
m_imageList = NULL;
m_scrollOffset = 0;
+ m_colBeingDragged = -1;
}
bool wxHeaderCtrl::Create(wxWindow *parent,
// notice that we need to store the string we use the pointer to until we
// pass it to the control
hdi.mask |= HDI_TEXT;
- wxWxCharBuffer buf = col.GetTitle().wx_str();
+ wxWxCharBuffer buf = col.GetTitle().t_str();
hdi.pszText = buf.data();
hdi.cchTextMax = wxStrlen(buf);
case HDN_ITEMCLICK:
case HDN_ITEMDBLCLICK:
evtType = GetClickEventType(code == HDN_ITEMDBLCLICK, nmhdr->iButton);
+
+ // We're not dragging any more.
+ m_colBeingDragged = -1;
break;
// although we should get the notifications about the right clicks
// ASCII and Unicode versions of this message
case HDN_BEGINTRACKA:
case HDN_BEGINTRACKW:
- // non-resizeable columns can't be resized no matter what, don't
+ // non-resizable columns can't be resized no matter what, don't
// even generate any events for them
if ( !GetColumn(idx).IsResizeable() )
{
}
break;
+ // The control is not supposed to send HDN_TRACK when using
+ // HDS_FULLDRAG (which we do use) but apparently some versions of
+ // comctl32.dll still do it, see #13506, so catch both messages
+ // 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) )
{
if ( nmhdr->iItem == -1 )
break;
+ // If we are dragging a column that is not draggable and the mouse
+ // is moved over a different column then we get the column number from
+ // the column under the mouse. This results in an unexpected behaviour
+ // if this column is draggable. To prevent this remember the column we
+ // are dragging for the complete drag and drop cycle.
+ if ( m_colBeingDragged == -1 )
+ {
+ m_colBeingDragged = idx;
+ }
+
// column must have the appropriate flag to be draggable
- if ( !GetColumn(idx).IsReorderable() )
+ if ( !GetColumn(m_colBeingDragged).IsReorderable() )
{
veto = true;
break;
order = MSWFromNativeOrder(order);
evtType = wxEVT_COMMAND_HEADER_END_REORDER;
+
+ // We (successfully) ended dragging the column.
+ m_colBeingDragged = -1;
break;
case NM_RELEASEDCAPTURE:
evtType = wxEVT_COMMAND_HEADER_DRAGGING_CANCELLED;
+
+ // Dragging the column was cancelled.
+ m_colBeingDragged = -1;
break;
}