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
{
// 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