X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e3a6a6b2bc15ddda1d614dd232d37e59ad024044..aeb500e64cfc83781e462b68feae19118b9cb105:/src/msw/textctrl.cpp diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 276df78633..cd347f4764 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -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; }