What is the maximum length for the text string contained in a CEdit control in MFC? I get a beep when trying to add a character after the character 30001 is this documented anywhere? Can I display longer texts in a CEdit? Should I use another control?
As "Windows programmer" says down below, the text length limit is not the same when the user types as when we programatically set the text using SetWindowText. The limit for setting a text programatically is not mentioned anywhere. The default text lentgth limit for the user typing is wrong. (see my own post below).
I'm guessing that after I call pEdit->SetLimitText(0) the limit for both programatically and user input text length is 7FFFFFFE bytes. Am I right?
In vista, when pasting text longer than 40000 characters into a CEdit, it becomes unresponsive. It does not matter if I called SetLimitText(100000) previously.
I found the documentation is wrong when mentioning the default size for a single line CEdit control in vista.
I ran this code:
the documentation states:
which is apparently wrong.
"(in characters it can display)" != "when trying to add a character".
"when trying to add a character" == "The maximum number of TCHARs the user can enter" unless you mean programmatically trying to add a character.
"0x7FFFFFFE characters" != "0x7FFFFFFE bytes" except sometimes, a fact which the quoted MSDN text understands sometimes.
I'll bet no one knows the answer to the original question. But "0x7FFFFFFE bytes" is likely one of many limits.
You can find out what the maximum is for your control by calling CEdit::GetLimitText() on your control. This returns the maximum size for character data in bytes. You can change the maximum size using the CEdit::SetLimitText() function.
The SetLimitText() function is equivalent to sending an EM_SETLIMITTEXT message. The documentation for that message gives the maximum sizes that can be used, but since these are MSDN links that will probably be broken by tomorrow, I'll copy the relevant information :)
The UINT parameter is interpreted as:
Also, from the Remarks section:
I assume they meant 0xFFFFFFFF instead of -1 in the second paragraph there...