diff --git a/interface/wx/listctrl.h b/interface/wx/listctrl.h index bb6865f7e2..fa380eeb01 100644 --- a/interface/wx/listctrl.h +++ b/interface/wx/listctrl.h @@ -214,9 +214,15 @@ public: /** Deletes all items in the list control. - @note This function does @e not send the @c wxEVT_COMMAND_LIST_DELETE_ITEM - event because deleting many items from the control would be too slow - then (unlike wxListCtrl::DeleteItem). + This function does @e not send the @c wxEVT_COMMAND_LIST_DELETE_ITEM + event because deleting many items from the control would be too slow + then (unlike wxListCtrl::DeleteItem) but it does send the special @c + wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS event if the control was not empty. + If it was already empty, nothing is done and no event is sent. + + @return @true if the items were successfully deleted or if the control + was already empty, @false if an error occurred while deleting the + items. */ bool DeleteAllItems(); diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 484443466f..997c3ca9bc 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1464,7 +1464,9 @@ bool wxListCtrl::DeleteItem(long item) // Deletes all items bool wxListCtrl::DeleteAllItems() { - return ListView_DeleteAllItems(GetHwnd()) != 0; + // Calling ListView_DeleteAllItems() will always generate an event but we + // shouldn't do it if the control is empty + return !GetItemCount() || ListView_DeleteAllItems(GetHwnd()) != 0; } // Deletes all items