文本编辑器的查询功能

来源:互联网 发布:淘宝怎么去除同款 编辑:程序博客网 时间:2024/05/16 11:22
<span style="color:#3333ff;">用delphi写文本编辑器时使用的查找功能代码段</span>
</pre><pre name="code" class="delphi">var    FoundPos:longint;    StartPos:integer;    str:string;begin    with MemoArr[CurPage] do    begin        StartPos:=SelStart+SelLength;        str:=Copy(lines.Text,StartPos+1,Length(lines.Text)-StartPos+1);        FoundPos:=Pos(FindDialog1.FindText,str);        if Found>0 then        begin            FoundPos:=FoundPos+StartPos;            SetFocus;            SelStart:=FoundPos-1;            SelLength:=Length(FindDialog1.FindText);        end        else            Messagebox(0,PChar(Format('未找到"%s"!!!',[FindDialog1.FindText])),'提示',MB_OK);    end;end;





0 0
原创粉丝点击