X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9085d634d9e29a877761ef51a01c740749648e33..24b3cc2c9632b7c6f0f0dd8f935688bd4d5e36f0:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index e6103c2025..2eeafd8a78 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -453,21 +453,32 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const if ( HasMultipleSelection() ) { - int no_sel = ListBox_GetSelCount(GetHwnd()); - if (no_sel != 0) { - int *selections = new int[no_sel]; - int rc = ListBox_GetSelItems(GetHwnd(), no_sel, selections); - - wxCHECK_MSG(rc != LB_ERR, -1, wxT("ListBox_GetSelItems failed")); + int countSel = ListBox_GetSelCount(GetHwnd()); + if ( countSel == LB_ERR ) + { + wxLogDebug(_T("ListBox_GetSelCount failed")); + } + else if ( countSel != 0 ) + { + int *selections = new int[countSel]; - aSelections.Alloc(no_sel); - for ( int n = 0; n < no_sel; n++ ) - aSelections.Add(selections[n]); + if ( ListBox_GetSelItems(GetHwnd(), + countSel, selections) == LB_ERR ) + { + wxLogDebug(wxT("ListBox_GetSelItems failed")); + countSel = -1; + } + else + { + aSelections.Alloc(countSel); + for ( int n = 0; n < countSel; n++ ) + aSelections.Add(selections[n]); + } delete [] selections; } - return no_sel; + return countSel; } else // single-selection listbox {