]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/listbox.cpp
Applied patch [ 774886 ] wxnotebook bug
[wxWidgets.git] / src / msw / listbox.cpp
index 6bcc8af1a88a01702d154815bbb2a1f9614dba9b..247ae933c8c29825ff5bbafcee5bb81810a5c2a9 100644 (file)
     #include  "wx/ownerdrw.h"
 #endif
 
-#ifndef __TWIN32__
-    #ifdef __GNUWIN32_OLD__
-        #include "wx/msw/gnuwin32/extra.h"
-    #endif
+#ifdef __GNUWIN32_OLD__
+    #include "wx/msw/gnuwin32/extra.h"
 #endif
 
 IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
@@ -147,7 +145,7 @@ bool wxListBox::Create(wxWindow *parent,
     if (m_windowStyle & wxLB_SORT)
         wstyle |= LBS_SORT;
 
-#if wxUSE_OWNER_DRAWN
+#if wxUSE_OWNER_DRAWN && !defined(__WXWINCE__)
     if ( m_windowStyle & wxLB_OWNERDRAW ) {
         // we don't support LBS_OWNERDRAWVARIABLE yet
         wstyle |= LBS_OWNERDRAWFIXED;
@@ -456,8 +454,7 @@ wxString wxListBox::GetString(int N) const
 
     // +1 for terminating NUL
     wxString result;
-    ListBox_GetText(GetHwnd(), N, result.GetWriteBuf(len + 1));
-    result.UngetWriteBuf();
+    ListBox_GetText(GetHwnd(), N, wxStringBuffer(result, len + 1));
 
     return result;
 }
@@ -585,13 +582,15 @@ void wxListBox::SetHorizontalExtent(const wxString& s)
             oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
 
         GetTextMetrics(dc, &lpTextMetric);
-        int i;
-        for (i = 0; i < m_noItems; i++)
+
+        // FIXME: buffer overflow!!
+        wxChar buf[1024];
+        for (int i = 0; i < m_noItems; i++)
         {
-            int len = (int)SendMessage(GetHwnd(), LB_GETTEXT, i, (LONG)wxBuffer);
-            wxBuffer[len] = 0;
+            int len = (int)SendMessage(GetHwnd(), LB_GETTEXT, i, (LPARAM)buf);
+            buf[len] = 0;
             SIZE extentXY;
-            ::GetTextExtentPoint(dc, (LPTSTR)wxBuffer, len, &extentXY);
+            ::GetTextExtentPoint(dc, buf, len, &extentXY);
             int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
             if (extentX > largestExtent)
                 largestExtent = extentX;
@@ -703,7 +702,11 @@ bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
 
     MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item;
 
+#ifdef __WXWINCE__
+    HDC hdc = GetDC(NULL);
+#else
     HDC hdc = CreateIC(wxT("DISPLAY"), NULL, NULL, 0);
+#endif
 
     wxDC dc;
     dc.SetHDC((WXHDC)hdc);