X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fd7ab28c5e655d496d1765143eab0b649cb54a4e..baaae89f09ece7ab8a17570ee535683b9d14aeda:/src/msw/listbox.cpp?ds=inline diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 6d1f05a556..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 { @@ -516,12 +527,15 @@ wxListBox::DoInsertItems(const wxArrayString& items, int pos) int idx = ListBox_InsertString(GetHwnd(), i + pos, items[i]); #if wxUSE_OWNER_DRAWN - wxOwnerDrawn *pNewItem = CreateItem(idx); - pNewItem->SetName(items[i]); - pNewItem->SetFont(GetFont()); - m_aItems.Insert(pNewItem, idx); + if ( m_windowStyle & wxLB_OWNERDRAW ) + { + wxOwnerDrawn *pNewItem = CreateItem(idx); + pNewItem->SetName(items[i]); + pNewItem->SetFont(GetFont()); + m_aItems.Insert(pNewItem, idx); - ListBox_SetItemData(GetHwnd(), idx, pNewItem); + ListBox_SetItemData(GetHwnd(), idx, pNewItem); + } #endif // wxUSE_OWNER_DRAWN }