I'm writing a WordPad clone with wxWidget. The text control should be a native Windows control.
A strange thing appeared when trying to copy rather large amount of text (around 80000 characters) both with the wxTextCtrl::Paste function and with SendMessage and WM_PASTE: at first attempt only about 30000 characters are pasted, at second attempt more but still not all and only at third attempt is everything pasted successfully. It looks as if some sort of internal buffer is incrementally enlarged and if it cannot be made large enough with one step, only as much as pasted as currently possible (and at next attempt the buffer is enlarged by the same step).
Has anyone else experienced this and is there a solution?
I also discovered the same behaviour in an older no-rich-text Notepad clone of mine (also coded with wxWidgets), so I doubt it is just some undefined behaviour on my part.
The same behaviour can be observed for example with this code (add WS_VSCROLL to the rich edit controls and try to paste an enormous lot of text into it).
It appears that indeed text controls have a default size how much text can be typed or pasted into them (and wxWidgets apparently tries to increase that internally but doesn't for some reason get the size right and instead increases the max limit in fixed steps?).
Currently I just put this in the text editors constructor, so it would let me at least paste up to around 1000000 characters:
However, since it is a tabbed program and can have many text controls open, is it a good idea to set that kind of max size to any text control the program might have?
//increase text limit to allow larger documents to be pasted
SendMessage((HWND)GetHandle(), EM_EXLIMITTEXT, 0, 1 << 20);