顶行设定:
procedure TSRichEdit.SetTopLine(Value: integer);
{Put selected line at top of memo}
var
tl: integer;
begin
tl := Value;
if tl < 0 then tl := 0;
if tl > Lines.Count - 1 then tl := Lines.Count - 1;
SendMessage(Handle, EM_LINESCROLL, 0, tl - SendMessage(Handle, EM_GETFIRSTVISIBLELINE, 0, 0));
end;
光标定位到某一行:
procedure TSRichEdit.SetCurrentLine(Value: integer);
{Put caret on start of selected line}
var
cl: integer;
begin
cl := Value;
{Restrict range to available lines}
if cl < 0 then cl := 0;
if cl > Lines.Count - 1 then cl := Lines.Count - 1;
SelLength := 0;
SelStart := SendMessage(Handle, EM_LINEINDEX, cl, 0);
end;
光标定位到某一列:
procedure TSRichEdit.SetCurrentPosition(Value: integer);
var
cl: integer;
cp: integer;
begin
cl := GetCurrentLine;
cp := Value;
if cp < 0 then cp := 0;
if (cp > Length(Lines[cl])) then cp := Length(Lines[cl]);
{Put caret in selected position}
SelLength := 0;
SelStart := SendMessage(Handle, EM_LINEINDEX, cl, 0) + cp;
end;
光标定位到指定的坐标点 richedit1.Perform(WM_LBUTTONDOWN, MK_LBUTTON, MakeLong(X, Y))