“文本超出备忘容量”;错误 [英] "Text exceeds memo capacity" error
问题描述
我有一个TMemo,尝试在其中加载文本,但出现以下错误:文本超出了备忘录的容量。代码是这样的:Memo1.Lines.LoadFromFile(s)
在Delphi 7 / Win 7下,TMemo的限制是多少?我知道在Win95 / 98下有64KB的限制。
I have a TMemo in which I tried to load text but I get this error: "Text exceeds memo capacity". The code is this: Memo1.Lines.LoadFromFile(s) What is the limit for TMemo under Delphi 7/Win 7? I knew there was a 64KB limit but under Win95/98.
注意:此错误是用户发送的屏幕截图。我可以成功加载大文件(5-10 MB)。
Note: This error is a screenshot sent by a user. I can successfully load large files (5-10 MB).
更新:
这次我在此行中收到一个新的错误报告:
I got a new bug report this time at this line:
procedure TCLog.Add (s: string; Cl: TColor);
begin
SelStart:= Length(Text);
SelAttributes.Color:= Cl;
S:= GenerateString(Indent, ' ')+ S;
TRY
Lines.Add(s); <------------------------ HERE
EXCEPT
on E: Exception DO
begin
MesajError('Cannot store string '+ s);
raise; // re-raise the currently caught exception
end;
END;
if AutoScroll
then LogScroll;
end;
推荐答案
我已经用500,000个字符的String测试了TMemo,并且它的工作原理是:
I have tested TMemo with a String of 500,000 characters and it worked:
procedure TForm5.Button1Click(Sender: TObject);
VAR s: string;
begin
s:= GenerateString(1000000, 'x');
Memo1.Text:= s;
end;
虽然需要20秒。
后来,我用TRichEdit替换了TEdit,但遇到了其他问题。最后,我意识到罪魁祸首是一个包含#0字符的字符串。遇到此字符时,看起来好像TRichEdit搞砸了。
Later I have replaced the TEdit with a TRichEdit and I had further problems. In the end I realized that the culprit was a string that contained the #0 character. Looks like TRichEdit screws up when it encounter this character.
这篇关于“文本超出备忘容量”;错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!