如果你这样做:
Edit1.Text := StringOfChar('X', 37440);
它将显示文本,但是如果您这样做:
Edit1.Text := StringOfChar('X', 37441);
文本不会出现。
有人知道为什么吗?
如果这是一个错误,除了将所有现有组件替换为 TMemo 之外,还有另一种调整方法吗?
到底为什么是 37440?
最佳答案
从表面上看,您应该能够使用 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.
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.
此消息由 TEdit
的 MaxLength
属性公开。
但是,将 MaxLength
设置为较大的值似乎没有帮助。我无法说服单行编辑控件显示大量字符。
我怀疑您唯一可行的选择是使用多行编辑控件,即 TMemo
。
我确信 MS 会争辩说,单行编辑控件的设计目的不是容纳数千个字符,因此他们没有动力让该控件变得更强大。
FWIW,使用 Unicode 版本的控件,截止值似乎是 37444 而不是 37440!
关于delphi - 为什么TEdit只显示长度等于或小于37440个字符的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17476973/