- // Only necessary if we want a horizontal scrollbar
- if (!(m_windowStyle & wxHSCROLL))
- return;
- TEXTMETRIC lpTextMetric;
-
- if (s != "")
- {
- int existingExtent = (int)SendMessage(hwnd, LB_GETHORIZONTALEXTENT, 0, 0L);
- HDC dc = GetWindowDC(hwnd);
- HFONT oldFont = 0;
- if (GetFont() && GetFont()->GetResourceHandle())
- oldFont = ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
-
- GetTextMetrics(dc, &lpTextMetric);
- SIZE extentXY;
- ::GetTextExtentPoint(dc, (LPSTR) (const char *)s, s.Length(), &extentXY);
- int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
-
- if (oldFont)
- ::SelectObject(dc, oldFont);
-
- ReleaseDC(hwnd, dc);
- if (extentX > existingExtent)
- SendMessage(hwnd, LB_SETHORIZONTALEXTENT, LOWORD(extentX), 0L);
- return;
- }
- else
- {
- int largestExtent = 0;
- HDC dc = GetWindowDC(hwnd);
- HFONT oldFont = 0;
- if (GetFont() && GetFont()->GetResourceHandle())
- oldFont = ::SelectObject(dc, (HFONT) GetFont()->GetResourceHandle());
-
- GetTextMetrics(dc, &lpTextMetric);
- int i;
- for (i = 0; i < m_noItems; i++)
- {
- int len = (int)SendMessage(hwnd, LB_GETTEXT, i, (LONG)wxBuffer);
- wxBuffer[len] = 0;
- SIZE extentXY;
- ::GetTextExtentPoint(dc, (LPSTR)wxBuffer, len, &extentXY);
- int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
- if (extentX > largestExtent)
- largestExtent = extentX;
- }
- if (oldFont)
- ::SelectObject(dc, oldFont);
+ wxCHECK_RET( pos >= 0 && pos <= m_noItems,
+ wxT("invalid index in wxListBox::InsertItems") );
+
+ int nItems = items.GetCount();
+ for ( int i = 0; i < nItems; i++ )
+ ListBox_InsertString(GetHwnd(), i + pos, items[i]);
+ m_noItems += nItems;