简体   繁体   English

为什么TEdit只显示长度等于或小于37440个字符的文本?

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

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? 如果这是一个错误,还有另一种方法可以调整而不是将所有现有组件替换为TMemo吗?
Why 37440 Anyway? 为什么选择37440?

On the face of it you ought to be able to control this using the EM_LIMITTEXT message: 从表面EM_LIMITTEXT ,您应该能够使用EM_LIMITTEXT消息来控制它:

The EM_LIMITTEXT message limits only the text the user can enter. EM_LIMITTEXT消息仅限制用户可以输入的文本。 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. 发送消息时,它不会影响编辑控件中已有的任何文本,也不会影响WM_SETTEXT消息复制到编辑控件的文本长度。 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. 如果应用程序使用WM_SETTEXT消息将更多文本放入编辑控件中,而不是在EM_LIMITTEXT消息中指定,则用户可以编辑编辑控件的全部内容。

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. 在调用EM_LIMITTEXT之前,用户可以在编辑控件中输入的文本量的默认限制为32,767个字符。

And this message is exposed by the MaxLength property of TEdit . 此消息由TEditMaxLength属性公开。

However, setting MaxLength to a large value doesn't appear to help. 但是,将MaxLength设置为较大的值似乎没有帮助。 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 . 我怀疑唯一可行的选择是使用多行编辑控件,即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. 我确信MS会认为单行编辑控件不是为了容纳数千个字符而设计的,所以他们没有动力让这个控件更有能力。

FWIW, with the Unicode version of the control, the cutoff appears to be at 37444 rather than 37440! FWIW,使用控件的Unicode版本,截止值似乎是在3474而不是37440!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM