if FoundAt <> -1 then
begin
SetFocus;
SelStart := FoundAt - 2;//这是VCL的Bug
if SelStart < 0 then SelStart := 0;//
SelLength := Length(FindDialog1.FindText);
end;
begin
FindDialog1.Position := Point(RichEdit1.Left + RichEdit1.Width, RichEdit1.Top);
FindDialog1.Execute;
end;
procedure TForm1.FindDialog1Find(Sender: TObject);
var
FoundAt: LongInt;
StartPos, ToEnd: Integer;
begin
with RichEdit1 do
begin
{ begin the search after the current selection if there is one }
{ otherwise, begin at the start of the text }
if SelLength <> 0 then
StartPos := SelStart + SelLength
else
StartPos := 0;
{ ToEnd is the length from StartPos to the end of the text in the rich edit control }
ToEnd := Length(Text) - StartPos;
FoundAt := FindText(FindDialog1.FindText, StartPos, ToEnd, [stMatchCase]);
if FoundAt <> -1 then
begin
SetFocus;
SelStart := FoundAt;
SelLength := Length(FindDialog1.FindText);
end;
end;
end;
目前看到的信息是
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOutOfResources with message 'RichEdit line insertion error'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
这个是语言方面的异常(Language Exceptions),目前尚未找到原因,其实这个异常可以屏蔽
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
try
for i:=0 to RichEdit2.Lines.Count-1 do
RichEdit1.Lines.Add(RichEdit2.lines.Strings[i]);
except
end;
如果找不出原因用这个屏蔽一下也可以救急的,这是一个很好的问题,本人收藏之
end;
首先声明:1、我的程序必需要用RichEdit,不能用Memo
2、程序要一行一行的向RichEdit里添加文本。
我写的程序突然遇到一个问题,那就是RichEdit遇到希腊字母、俄文字母都会出现“RichEdit line insertion error”这样的错误。演示程序代码如下:
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
for i:=0 to RichEdit2.Lines.Count-1 do
RichEdit1.Lines.Add(RichEdit2.lines.Strings[i]);
end;