X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1ddb283ad51e845a8f7d18e3e1efc07328b99142..15cac64f7564d48c274c6490774a77bd8c09f808:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 9252783bed..82b06b1432 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -177,7 +177,8 @@ bool wxListBox::Create(wxWindow *parent, Append(choices[i]); } - // now we can compute our best size correctly, so do it if necessary + // now we can compute our best size correctly, so do it again + InvalidateBestSize(); SetInitialSize(size); return true; @@ -355,15 +356,6 @@ void wxListBox::DoSetItemClientData(unsigned int n, void *clientData) wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetClientData") ); -#if wxUSE_OWNER_DRAWN - if ( m_windowStyle & wxLB_OWNERDRAW ) - { - // client data must be pointer to wxOwnerDrawn, otherwise we would crash - // in OnMeasure/OnDraw. - wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes")); - } -#endif // wxUSE_OWNER_DRAWN - if ( ListBox_SetItemData(GetHwnd(), n, clientData) == LB_ERR ) wxLogDebug(wxT("LB_SETITEMDATA failed")); } @@ -473,8 +465,6 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items, pNewItem->SetName(items[i]); pNewItem->SetFont(GetFont()); m_aItems.Insert(pNewItem, n); - - ListBox_SetItemData(GetHwnd(), n, pNewItem); } #endif // wxUSE_OWNER_DRAWN AssignNewItemClientData(n, clientData, i, type); @@ -532,9 +522,6 @@ void wxListBox::SetString(unsigned int n, const wxString& s) { // update item's text m_aItems[n]->SetName(s); - - // reassign the item's data - ListBox_SetItemData(GetHwnd(), n, m_aItems[n]); } #endif //USE_OWNER_DRAWN @@ -746,17 +733,12 @@ bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false ); DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item; - UINT itemID = pStruct->itemID; // the item may be -1 for an empty listbox - if ( itemID == (UINT)-1 ) + if ( pStruct->itemID == (UINT)-1 ) return false; - LRESULT data = ListBox_GetItemData(GetHwnd(), pStruct->itemID); - - wxCHECK( data && (data != LB_ERR), false ); - - wxListBoxItem *pItem = (wxListBoxItem *)data; + wxListBoxItem *pItem = (wxListBoxItem *)m_aItems[pStruct->itemID]; wxDCTemp dc((WXHDC)pStruct->hDC); wxPoint pt1(pStruct->rcItem.left, pStruct->rcItem.top);