]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
Don't depend on wx/dcmemory.h to include wx/dcclient.h for wxPaintDC
[wxWidgets.git] / src / msw / textctrl.cpp
index 276df78633511438a047059ca6ee72d3ccac4310..cd347f4764966d4b8d9afdd7168bd504e4d63450 100644 (file)
@@ -468,30 +468,32 @@ wxString wxTextCtrl::GetRange(long from, long to) const
         int len = GetWindowTextLength(GetHwnd());
         if ( len > from )
         {
-            // alloc one extra WORD as needed by the control
-            wxChar *p = str.GetWriteBuf(++len);
+            {
+                // alloc one extra WORD as needed by the control
+                wxStringBuffer tmp(str, ++len);
+                wxChar *p = tmp;
 
-            TEXTRANGE textRange;
-            textRange.chrg.cpMin = from;
-            textRange.chrg.cpMax = to == -1 ? len : to;
-            textRange.lpstrText = p;
+                TEXTRANGE textRange;
+                textRange.chrg.cpMin = from;
+                textRange.chrg.cpMax = to == -1 ? len : to;
+                textRange.lpstrText = p;
 
-            (void)SendMessage(GetHwnd(), EM_GETTEXTRANGE, 0, (LPARAM)&textRange);
+                (void)SendMessage(GetHwnd(), EM_GETTEXTRANGE,
+                                  0, (LPARAM)&textRange);
 
-            if ( m_verRichEdit > 1 )
-            {
-                // RichEdit 2.0 uses just CR ('\r') for the newlines which is
-                // neither Unix nor Windows style - convert it to something
-                // reasonable
-                for ( ; *p; p++ )
+                if ( m_verRichEdit > 1 )
                 {
-                    if ( *p == _T('\r') )
-                        *p = _T('\n');
+                    // RichEdit 2.0 uses just CR ('\r') for the
+                    // newlines which is neither Unix nor Windows
+                    // style - convert it to something reasonable
+                    for ( ; *p; p++ )
+                    {
+                        if ( *p == _T('\r') )
+                            *p = _T('\n');
+                    }
                 }
             }
 
-            str.UngetWriteBuf();
-
             if ( m_verRichEdit == 1 )
             {
                 // convert to the canonical form - see comment below
@@ -1196,13 +1198,16 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
     len += sizeof(WORD);
 
     wxString str;
-    wxChar *buf = str.GetWriteBuf(len);
-
-    *(WORD *)buf = (WORD)len;
-    len = (size_t)::SendMessage(GetHwnd(), EM_GETLINE, lineNo, (LPARAM)buf);
-    buf[len] = 0;
+    {
+        wxStringBufferLength tmp(str, len);
+        wxChar *buf = tmp;
 
-    str.UngetWriteBuf(len);
+        *(WORD *)buf = (WORD)len;
+        len = (size_t)::SendMessage(GetHwnd(), EM_GETLINE,
+                                    lineNo, (LPARAM)buf);
+        buf[len] = 0;
+        tmp.SetLength(len);
+    }
 
     return str;
 }