用 FindDialog 查找我没有用过,不过自己找我是做过:
其实很简单,把两个字符串统统反序,再找就可以了:)
function FindUp(RichEdit: TRichEdit; SubStr: string): Integer;
var
i, SrcLen, DstLen: Integer;
Txt: string;
begin
SrcLen := Length(RichEdit.Text);
Txt := RichEdit.Text;
DstLen := Length(SubStr);
for i := 1 to SrcLen do // 主串反序
Txt := Txt[SrcLen + 1 - i];
for i := 1 to DstLen do // 子串反序
SubStr := SubStr[DstLen + 1 - i];
Result := AnsiPos(SubStr, Txt);
end;
使用:
RichEdit1.SelStart := FindUp(RichEdit1, 'hello');
RichEdit1.Perform(EM_SCROLLCARET, 0, 0);