增加 TRichEdit 的大小/限制?

发布于 2024-11-07 22:23:04 字数 556 浏览 6 评论 0原文

我在使用 TRichEdit 时遇到一些问题。

第一个问题是,如果我尝试将剪贴板中的大量文本粘贴到空的 TRichEdit 中,它会截断文本的底部。

我猜第二个问题与第一个问题有关,我似乎限制了 TRichEdit 可以显示的字符数量,因此从剪贴板粘贴会丢失一些数据。

如果我粘贴到 TJvRichEdit (Jedi) 中,效果很好,显然因为这是一个完全不同的组件。

此时此刻,我想要 TRichEdit 的解决方案,因为我正在使用很多过程/函数等,如果我更改为不同的 Rich Edit 类,那么我将不得不编辑很多代码才能工作。

所以基本上我要问的是:

  • TRichEdit 有限制吗?我确信是有的。
  • 如何增加 TRichEdit 的限制以接受更多字符和行等。

请仅提供 TRichEdit 的建议/解决方案。

编辑

没关系,使用以下方法找到答案:

RichEdit11.MaxLength := $7FFFFFF0;

I am having some issues with the TRichEdit.

The first issue is if I try to paste a lot of text from the clipboard into a empty TRichEdit, it truncates the bottom of the text.

The second issue, which I guess ties into the first issue, is that I seem to be limited to how many characters the TRichEdit can display, hence pasting from the clipboard is losing some of the data.

If I paste into a TJvRichEdit (Jedi), that works fine, obviously because that is a completely different component.

At this moment in time I would like a solution for the TRichEdit because I am using a lot of procedures/functions etc, if I change to a different Rich Edit class then I will have to edit a lot of my code to work.

So basically what I am asking is:

  • Is there a limit in the TRichEdit? which I am sure there is.
  • How can I increase the limit of the TRichEdit to accept more characters and lines etc.

Please provide advice/solution for TRichEdit only.

EDIT

never mind found the answer using:

RichEdit11.MaxLength := $7FFFFFF0;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何以心动 2024-11-14 22:23:04

引用 David Pate 在 新闻组

以下注释适用于使用 Windows Richedit 版本 1 控件的 Delphi 版本。我知道这包括版本 7 之前的所有 Delphi 版本。(我不知道当您在各种 NT/2000 版本的 Windows 上运行在这些版本中编译的程序时会出现什么情况,尽管 Windows XP 的行为如所描述的那样。)

问:什么Richedit 可以容纳的文本量有限制吗?答:在这一点上,帮助文件(Delphi 帮助和 Win32 SDK)令人困惑、矛盾且不正确。有 5 个限制需要考虑

  1. 最大容量:“硬连线”限制,即 RichEdit 文本缓冲区的最大大小。它比 2 GB 少了 2 个字节。请注意,这是理论极限;实际上,该限制将由计算机的内存决定。

  2. Capacity:当前缓冲区的实际大小。默认情况下,它是 64Kb,但可以通过多种方式调整大小。

  3. “键盘限制”:超出此限制,无法通过键盘输入添加字符。它通常与容量不同,但与容量一样,默认情况下为 64Kb,并且可以通过多种方式调整大小。

  4. tRichEdit 对象的 MaxLength 属性。默认值 0 将容量和“键盘限制”设置为 64Kb。

  5. 行数限制:理论上大约是 1.34 亿行,但实际上,您得到的可能会比这个少得多。最大行数似乎取决于几个因素,包括可用内存量和行的平均长度。我发现我可以获得大约 15 万到 20 万行。另请注意,据报道,Windows 95 Richedit 控件的某些版本有时在添加超过几百行时会引发异常。这似乎是由于控件中的错误造成的,并已在以后的版本中得到纠正。

问:如何增加 tRichEdit 可以容纳的文本量?

答:当您以编程方式添加文本时,容量和“键盘限制”都会调整大小以适应要添加的文本。通过以编程方式添加文本,我的意思是使用 tRichEdit.Lines 属性的 Add、Append、AddStrings 或 Assign 方法或 tRichEdit 的 LoadFromFile、LoadFromStream 或 SetTextBuf 方法中的任何一个。请注意,以这种方式添加文本不会更新 MaxLength 属性。

B. 通过使用 MaxLength 属性。这会将“键盘限制”设置为传递给 MaxLength 的值。如果现有容量小于 MaxLength,它还会增加容量以匹配“键盘限制”。请注意,您不能使用 MaxLength 来减小容量,并且如果传递的值小于控件中当前文本的长度,则更改 MaxLength 无效。要将容量和“键盘限制”增加到相同的值,请将 tRichEdit.MaxLength 设置为所需的值。要在对象检查器中设置最大大小,请使用值 2147483645 ($7FFFFFFD)。要以编程方式设置它,使用 .MaxLength := System.MaxInt-2; 更简单。 EM_LIMITTEXT 和 EM_EXLIMITTEXT 消息也可用于更改“键盘限制”和容量,但我通常不建议使用它们,因为如果这样做,您将不会更新 MaxLength 属性。

Quoting an answer given by David Pate from the newsgroups:

The following remarks apply to the versions of Delphi that use the Windows Richedit version 1 control. I understand that this includes all Delphi versions prior to version 7. (I do not know what the situation is when you run programs compiled in these versions on the various NT/2000 versions of Windows although Windows XP behaves as described.)

Q. What is the limit to the amount of text that a Richedit can hold? A. The help files (Delphi help and Win32 SDK) are confusing, contradictory and incorrect on this point. There are 5 limits to be considered

  1. The Maximum Capacity: the "hard-wired" limit, i.e the maximum size of the RichEdit's text buffer. It is 2 bytes less than 2 Gb. Note that this is the theoretical limit; in practice the limit will be determined by your computer's memory.

  2. The Capacity: the actual size of the current buffer. By default, it is 64Kb but can be resized by several means.

  3. The "Keyboard limit": the limit beyond which characters cannot be added by typing from the keyboard. It is often different from the Capacity but, like the Capacity, it is by default, 64Kb and can be resized by several means.

  4. The MaxLength property of the tRichEdit object. The default of 0 sets both the Capacity and "Keyboard limit" to 64Kb.

  5. The line-number limit: theoretically this is around 134 million, but in practice, you can expect to get much less than this. The maximum number of lines seems to depend on several factors including the amount of memory available and the average length of the lines. I find that I can get around 150 thousand to 200 thousand lines. Note also that it has been reported that some releases of the Windows 95 Richedit control sometimes throw an exception when more than a few hundred lines are added. This appears to be due to a bug in the control and to have been corrected in later releases..

Q. How can I increase the amount of text that a tRichEdit can hold?

A. When you add text programmatically, both the Capacity and the "Keyboard limit" are resized to accommodate the text being added. By adding text programmatically, I mean using any of the Add, Append, AddStrings or Assign methods of the tRichEdit.Lines property or the LoadFromFile, LoadFromStream or SetTextBuf methods of tRichEdit. Note that adding text in this way does not update the MaxLength property.

B. By using the MaxLength property. This sets the "Keyboard limit" to the value passed to MaxLength. It also increases the Capacity to match the "Keyboard limit" if the existing Capacity is less than MaxLength. Note that you cannot use MaxLength to reduce the Capacity and that changing MaxLength has no effect if the value passed is less than the length of the text currently in the control. To increase the Capacity and the "Keyboard limit" to the same value, set the tRichEdit.MaxLength to the desired value. To set the maximum size in the Object Inspector, use the value 2147483645 ($7FFFFFFD). To set it programmatically it is simpler to use .MaxLength := System.MaxInt-2;. The EM_LIMITTEXT and EM_EXLIMITTEXT messages may also be used to change the "Keyboard limit" and Capacity but I'd not normally recommend using them since, if you do, you will not be updating the MaxLength property.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文