regenerated with correct substitutions for COND_WXUNIV_0 (fixes wxAdv build problems)
[wxWidgets.git] / src / msw / listbox.cpp
index 7b7fcc8d185b8fe8c6a9e848785383f043222126..a34af86c4167a17389dcc39f7973309a53be1805 100644 (file)
@@ -621,7 +621,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s)
         int existingExtent = (int)SendMessage(GetHwnd(), LB_GETHORIZONTALEXTENT, 0, 0L);
         HDC dc = GetWindowDC(GetHwnd());
         HFONT oldFont = 0;
-        if (GetFont().Ok() && GetFont().GetResourceHandle())
+        if (GetFont().Ok() && GetFont().GetResourceHandle() != 0)
             oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
 
         GetTextMetrics(dc, &lpTextMetric);
@@ -641,19 +641,16 @@ void wxListBox::SetHorizontalExtent(const wxString& s)
         int largestExtent = 0;
         HDC dc = GetWindowDC(GetHwnd());
         HFONT oldFont = 0;
-        if (GetFont().Ok() && GetFont().GetResourceHandle())
+        if (GetFont().Ok() && GetFont().GetResourceHandle() != 0)
             oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
 
         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;