X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/24ee1bef74a8f403ad3df207edd9d656648c4da5..4776c0b783a9776f94b049aecdc253d379686b6b:/src/msw/listbox.cpp?ds=sidebyside

diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp
index 52fe4d0c4d..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
     {