A
aikede
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的代码可以实现向下查找,但是向上查找要如何修改?
with REdt_Infodo
begin
if frDown in FindDialog1.Options then
begin
StartPos:=SelStart+SelLength;
ToEnd:=Length(Text) - StartPos;
ShowMessage(IntTostr(StartPos));
end
else
begin
ShowMessage(IntTostr(StartPos));
StartPos:=StartPos-SelLength;
ToEnd:=0;
end;
//ShowMessage(IntToStr(StartPos)+':'+IntToStr(ToEnd));
if frDown in FindDialog1.Options then
FoundAt:=FindText(FindDialog1.FindText, StartPos, ToEnd, SearchFlag);
{else
FoundAt:=FindText(FindDialog1.FindText,ToEnd ,StartPos , SearchFlag);}
if FoundAt<>-1 then
begin
SetFocus;
SelStart:=FoundAt;
SelLength:=Length(FindDialog1.FindText);
end
else
begin
SelLength:=0;
SelStart:=StartPos;
Application.MessageBox(PChar('未找到'+FindDialog1.FindText),'查找失败',Mb_Ok+Mb_IconError);
end;
end;
with REdt_Infodo
begin
if frDown in FindDialog1.Options then
begin
StartPos:=SelStart+SelLength;
ToEnd:=Length(Text) - StartPos;
ShowMessage(IntTostr(StartPos));
end
else
begin
ShowMessage(IntTostr(StartPos));
StartPos:=StartPos-SelLength;
ToEnd:=0;
end;
//ShowMessage(IntToStr(StartPos)+':'+IntToStr(ToEnd));
if frDown in FindDialog1.Options then
FoundAt:=FindText(FindDialog1.FindText, StartPos, ToEnd, SearchFlag);
{else
FoundAt:=FindText(FindDialog1.FindText,ToEnd ,StartPos , SearchFlag);}
if FoundAt<>-1 then
begin
SetFocus;
SelStart:=FoundAt;
SelLength:=Length(FindDialog1.FindText);
end
else
begin
SelLength:=0;
SelStart:=StartPos;
Application.MessageBox(PChar('未找到'+FindDialog1.FindText),'查找失败',Mb_Ok+Mb_IconError);
end;
end;