delphi查找对话框
生活随笔
收集整理的這篇文章主要介紹了
delphi查找对话框
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
procedure TForm1.FindDialog1Find(Sender: TObject);
var
? FoundAt: LongInt;
? StartPos, ToEnd: Integer;
begin
? with RichEdit1 do
? begin
??? //如果有要找的字符串,則將對話框顯示在當前字符串后面
??? //如果沒有找到,將其停在文件的開始位置
??? if SelLength <> 0 then
????? StartPos := SelStart + SelLength
??? else
????? StartPos := 0;
????? 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;
var
? FoundAt: LongInt;
? StartPos, ToEnd: Integer;
begin
? with RichEdit1 do
? begin
??? //如果有要找的字符串,則將對話框顯示在當前字符串后面
??? //如果沒有找到,將其停在文件的開始位置
??? if SelLength <> 0 then
????? StartPos := SelStart + SelLength
??? else
????? StartPos := 0;
????? 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;
總結
以上是生活随笔為你收集整理的delphi查找对话框的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Delphi中判断字母与汉字
- 下一篇: 只能输入数字