X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c07b0669cf4158e4e4d9a609b1202b9d6db1fb4d..66f75561893ea7b4bf429d1882d9cc0407ba932d:/src/msw/listbox.cpp?ds=sidebyside

diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp
index 53d60ce89b..97bbe92840 100644
--- a/src/msw/listbox.cpp
+++ b/src/msw/listbox.cpp
@@ -351,7 +351,11 @@ void wxListBox::DoSetSelection(int N, bool select)
 
     if ( HasMultipleSelection() )
     {
-        SendMessage(GetHwnd(), LB_SETSEL, select, N);
+        // Setting selection to -1 should deselect everything.
+        const bool deselectAll = N == wxNOT_FOUND;
+        SendMessage(GetHwnd(), LB_SETSEL,
+                    deselectAll ? FALSE : select,
+                    deselectAll ? -1 : N);
     }
     else
     {
@@ -689,20 +693,10 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
     if ( n == wxNOT_FOUND )
        return false;
 
-    // As we don't use m_oldSelections in single selection mode, we store the
-    // last item that we notified the user about in it in this case because we
-    // need to remember it to be able to filter out the dummy LBN_SELCHANGE
-    // messages that we get when the user clicks on an already selected item.
     if ( param == LBN_SELCHANGE )
     {
-        if ( !m_oldSelections.empty() && *m_oldSelections.begin() == n )
-        {
-            // Same item as the last time.
+        if ( !DoChangeSingleSelection(n) )
             return false;
-        }
-
-        m_oldSelections.clear();
-        m_oldSelections.push_back(n);
     }
 
     // Do generate an event otherwise.