Delphi Memo1 字符串快速查找定位


本文整理自网络,侵删。

 
procedure TForm1.Button3Click(Sender: TObject);
var
  I, L: Integer;

begin
  Memo1.WordWrap:= False;
  Memo1.Lines.LoadFromFile('Windows.pas');
  I:= Pos('finalization', Memo1.Text);
  if I > 0 then begin
    L := SendMessage(Memo1.Handle, EM_LINEFROMCHAR, I - 1, 0);
    ShowMessage('Found at line ' + IntToStr(L));
// if you need to select the text found:
    Memo1.SelStart := I - 1;
    Memo1.SelLength := Length('finalization');
    Memo1.SetFocus;
  end;
end;

相关阅读 >>

Delphi 获取系统桌面大小

Delphi system.sysutils.tmarshaller 与 system.tmarshal

Delphi twebbrowser与嵌入youtube视频崩溃

Delphi copy 从字符串中复制指定范围中的字符

Delphi filecreate 建立新文件

Delphi 自动复制到指定目录的代码

Delphi 简单的定时程序代码

Delphi 为 service application 添加描述文本的方法

Delphi 获取文件夹下包括子目录所有文件

Delphi xe(indy10)tidbytes转ansistring的实现

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...