+void
+wxListBox::DoInsertItems(const wxArrayString& items, int pos)
+{
+ wxCHECK_RET( pos >= 0 && pos <= m_noItems,
+ wxT("invalid index in wxListBox::InsertItems") );
+
+ int nItems = items.GetCount();
+ for ( int i = 0; i < nItems; i++ )
+ {
+ 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);
+
+ ListBox_SetItemData(GetHwnd(), idx, pNewItem);
+#endif // wxUSE_OWNER_DRAWN
+ }
+
+ m_noItems += nItems;
+
+ SetHorizontalExtent();
+}
+
+void wxListBox::SetString(int N, const wxString& s)
+{
+ wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxT("invalid index in wxListBox::SetString") );
+
+ // remember the state of the item
+ bool wasSelected = IsSelected(N);
+
+ void *oldData = NULL;
+ wxClientData *oldObjData = NULL;
+ if ( m_clientDataItemsType == wxClientData_Void )
+ oldData = GetClientData(N);
+ else if ( m_clientDataItemsType == wxClientData_Object )
+ oldObjData = GetClientObject(N);
+
+ // delete and recreate it
+ SendMessage(GetHwnd(), LB_DELETESTRING, N, 0);
+
+ int newN = N;
+ if ( N == m_noItems - 1 )
+ newN = -1;
+
+ ListBox_InsertString(GetHwnd(), newN, s);
+
+ // restore the client data
+ if ( oldData )
+ SetClientData(N, oldData);
+ else if ( oldObjData )
+ SetClientObject(N, oldObjData);
+
+ // we may have lost the selection
+ if ( wasSelected )
+ Select(N);
+
+#if wxUSE_OWNER_DRAWN
+ if ( m_windowStyle & wxLB_OWNERDRAW )
+ {
+ // 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
+}
+
+int wxListBox::GetCount() const
+{
+ return m_noItems;
+}
+
+// ----------------------------------------------------------------------------
+// helpers
+// ----------------------------------------------------------------------------
+