为什么TEdit只显示长度等于或小于37440个字符的文本? [英] Why does TEdit only shows text with length equals or less than 37440 characters?

查看:82
本文介绍了为什么TEdit只显示长度等于或小于37440个字符的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您这样做:

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

它将显示文本,但是如果您这样做:

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

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

该文本将不会出现.

有人知道为什么吗?
如果这是一个错误,那么还有另一种调整而不是将所有现有组件替换为TMemo的方法吗?
为什么还是37440?

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?

推荐答案

表面上,您应该能够使用

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

EM_LIMITTEXT消息仅限制用户可以输入的文本.发送消息时,它不会影响编辑控件中已有的任何文本,也不会影响WM_SETTEXT消息复制到编辑控件中的文本的长度.如果应用程序使用WM_SETTEXT消息向编辑控件中放置的文本多于EM_LIMITTEXT消息中指定的文本,则用户可以编辑该编辑控件的全部内容.

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.

在调用EM_LIMITTEXT之前,用户可以在编辑控件中输入的文本量的默认限制是32,767个字符.

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.

TEditMaxLength属性公开了此消息.

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

但是,将MaxLength设置为较大的值似乎没有帮助.我无法说服单行编辑控件显示大量字符.

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.

我怀疑唯一可行的选择是使用多行编辑控件,即TMemo.

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

我确信MS会争辩说,单行编辑控件的设计目的不是要容纳数千个字符,因此它们没有动力使该控件更强大.

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,使用控件的Unicode版本,截止日期似乎是37444,而不是37440!

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

这篇关于为什么TEdit只显示长度等于或小于37440个字符的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆