X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0c03f52d02470366a1b1370d918fa5779997e7f0..cc3977bf132d40cb66c6b488890ef67a396d4a0a:/src/msw/listctrl.cpp diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 6e526f3784..ed4d99e456 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1466,7 +1466,7 @@ bool wxListCtrl::DeleteItem(long item) bool wxListCtrl::DeleteAllItems() { // Calling ListView_DeleteAllItems() will always generate an event but we - // shouldn't do it if the control is empty + // shouldn't do it if the control is empty return !GetItemCount() || ListView_DeleteAllItems(GetHwnd()) != 0; } @@ -2238,22 +2238,6 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) eventType = wxEVT_COMMAND_LIST_DELETE_ITEM; event.m_itemIndex = iItem; - // delete the associated internal data - if ( wxMSWListItemData *data = MSWGetItemData(iItem) ) - { - const unsigned count = m_internalData.size(); - for ( unsigned n = 0; n < count; n++ ) - { - if ( m_internalData[n] == data ) - { - m_internalData.erase(m_internalData.begin() + n); - wxDELETE(data); - break; - } - } - - wxASSERT_MSG( !data, "invalid internal data pointer?" ); - } break; case LVN_INSERTITEM: @@ -2342,6 +2326,14 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) eventType = wxEVT_COMMAND_LIST_KEY_DOWN; event.m_code = wxMSWKeyboard::VKToWX(wVKey); + + if ( event.m_code == WXK_NONE ) + { + // We can't translate this to a standard key code, + // until support for Unicode key codes is added to + // wxListEvent we just ignore them. + return false; + } } event.m_itemIndex = @@ -2601,6 +2593,27 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) m_count = 0; return true; + case LVN_DELETEITEM: + // Delete the associated internal data. Notice that this can be + // done only after the event has been handled as the data could be + // accessed during the handling of the event. + if ( wxMSWListItemData *data = MSWGetItemData(event.m_itemIndex) ) + { + const unsigned count = m_internalData.size(); + for ( unsigned n = 0; n < count; n++ ) + { + if ( m_internalData[n] == data ) + { + m_internalData.erase(m_internalData.begin() + n); + wxDELETE(data); + break; + } + } + + wxASSERT_MSG( !data, "invalid internal data pointer?" ); + } + break; + case LVN_ENDLABELEDITA: case LVN_ENDLABELEDITW: // logic here is inverted compared to all the other messages