Ticket #15980: textctrl-append.patch

File textctrl-append.patch, 1.3 KB (added by awi, 4 years ago)

Patch to fix the issue.

  • \src/msw/textctrl.cpp

    diff -uNrBb wxWidgets-trunk\src/msw/textctrl.cpp wxWidgets-work\src/msw/textctrl.cpp
    old new  
    11371137
    11381138        UpdatesCountFilter ucf(m_updatesCount);
    11391139
     1140        int newLen = ::GetWindowTextLength(GetHwnd()) + valueDos.length();
    11401141        ::SendMessage(GetHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT,
    11411142                      // EM_REPLACESEL takes 1 to indicate the operation should be redoable
    11421143                      selectionOnly ? 1 : 0, wxMSW_CONV_LPARAM(valueDos));
    1143 
     1144        while( ::GetWindowTextLength(GetHwnd()) < newLen )
     1145        {
     1146            // Text size limit has been hit and added text has been truncated.
     1147            // Because text buffer has been increased in the background (EN_MAXTEXT message)
     1148            // we can undo the operation and try to add the text again.
     1149            if( selectionOnly )
     1150                Undo();
     1151            ::SendMessage(GetHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT,
     1152                          // EM_REPLACESEL takes 1 to indicate the operation should be redoable
     1153                          selectionOnly ? 1 : 0, wxMSW_CONV_LPARAM(valueDos));
     1154        }
    11441155        if ( !ucf.GotUpdate() && (flags & SetValue_SendEvent) )
    11451156        {
    11461157            SendUpdateEvent();