X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/84f7327f47d5895c8fcc056217945f1863f63fc6..5f3565a2fb3d678b03cf8547f37e56b1efe786f5:/src/msw/listbox.cpp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 84e7896bdf..120a38ce72 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -513,7 +513,7 @@ wxString wxListBox::GetString(int N) const // +1 for terminating NUL wxString result; - ListBox_GetText(GetHwnd(), N, wxStringBuffer(result, len + 1)); + ListBox_GetText(GetHwnd(), N, (wxChar*)wxStringBuffer(result, len + 1)); return result; } @@ -616,7 +616,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s) return; TEXTMETRIC lpTextMetric; - if ( !s.IsEmpty() ) + if ( !s.empty() ) { int existingExtent = (int)SendMessage(GetHwnd(), LB_GETHORIZONTALEXTENT, 0, 0L); HDC dc = GetWindowDC(GetHwnd()); @@ -646,14 +646,11 @@ void wxListBox::SetHorizontalExtent(const wxString& s) GetTextMetrics(dc, &lpTextMetric); - // FIXME: buffer overflow!! - wxChar buf[1024]; for (int i = 0; i < m_noItems; i++) { - int len = (int)SendMessage(GetHwnd(), LB_GETTEXT, i, (LPARAM)buf); - buf[len] = 0; + wxString str = GetString(i); SIZE extentXY; - ::GetTextExtentPoint(dc, buf, len, &extentXY); + ::GetTextExtentPoint(dc, str.c_str(), str.length(), &extentXY); int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth); if (extentX > largestExtent) largestExtent = extentX;