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