X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f186bd4d4035909759af0e5e9fcfd958a879ed6f..46405e36bf9962b251e77e5048e96bf6a54edb15:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 3e19b2a9f2..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 { @@ -686,7 +690,17 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) // We get events even when mouse is clicked outside of any valid item from // Windows, just ignore them. - return n != wxNOT_FOUND && SendEvent(evtType, n, true /* selection */); + if ( n == wxNOT_FOUND ) + return false; + + if ( param == LBN_SELCHANGE ) + { + if ( !DoChangeSingleSelection(n) ) + return false; + } + + // Do generate an event otherwise. + return SendEvent(evtType, n, true /* selection */); } WXLRESULT