Why does TEdit only shows text with length equals or less than 37440 characters?

别等时光非礼了梦想. 提交于 2019-12-10 13:51:48

问题


If you do this:

  Edit1.Text := StringOfChar('X', 37440);

It will show the text, however if you do this:

  Edit1.Text := StringOfChar('X', 37441);

The text will not appear.

Does anybody knows why?
If this is an error, there is another way of adjusting rather than replacing all existing components to TMemo?
Why 37440 Anyway?


回答1:


On the face of it you ought to be able to control this using the EM_LIMITTEXT message:

The EM_LIMITTEXT message limits only the text the user can enter. It does not affect any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control by the WM_SETTEXT message. If an application uses the WM_SETTEXT message to place more text into an edit control than is specified in the EM_LIMITTEXT message, the user can edit the entire contents of the edit control.

Before EM_LIMITTEXT is called, the default limit for the amount of text a user can enter in an edit control is 32,767 characters.

And this message is exposed by the MaxLength property of TEdit.

However, setting MaxLength to a large value doesn't appear to help. I cannot persuade a single line edit control to display a large number of characters.

I suspect the only viable option for you is to use a multi-line edit control, that is a TMemo.

I'm sure MS would argue that single line edit controls are not designed to hold thousands of characters and so they have no motivation to make that control more capable.

FWIW, with the Unicode version of the control, the cutoff appears to be at 37444 rather than 37440!



来源:https://stackoverflow.com/questions/17476973/why-does-tedit-only-shows-text-with-length-equals-or-less-than-37440-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!