procedure GotoRowCol(Row, Col : Integer; RichEdit : TRichEdit);
var
TextLen, i : Integer;
begin
if Row > RichEdit.Lines.Count then Exit;
TextLen := 0;
for i := 0 to Row - 1 do
TextLen := TextLen + Length(RichEdit.Lines) + 1;
if (Col <= Length(RichEdit.Lines[Row - 1])) and (Col > 0) then
TextLen := TextLen + Col - 1;
RichEdit.SelStart := TextLen - Length(RichEdit.Lines[Row - 1]);
SendMessage(RichEdit.Handle, EM_SCROLLCARET, 0,0);
end;
这个过程用来跳。我测试了我的保存 位置没有错但不知为何总是跳到相应的另一个位置 是这个过程写错吗?还是调用问题 调用为
Col := StrToInt64(Ini.ReadString('bookmark', 'col', '0'));
Row := StrToInt64(Ini.ReadString('bookmark', 'row', '0'));
if row>0 then
begin
gotorowcol(row,col,RichEdit1);
end else
showmessage('没有找到书签');
richedit1.setfocus;