高亮选中MEMO某一行-LMLPHP

选中第5行

//转到指定行并选中这行的文本
procedure SelectLine(Memo1: TMemo; ln: Integer);
begin
Memo1.SelStart := SendMessage(Memo1.Handle, EM_LINEINDEX, ln - , );
Memo1.SelLength := Length(Memo1.Lines[ln - ]);
end;

http://bbs.csdn.net/topics/110143548

//将滚动条定位到指定行
procedure ScrollToLine(Memo1: TMemo; ln: Integer);
begin
SendMessage(Memo1.Handle, EM_LINESCROLL, , -Memo1.Lines.Count);
SendMessage(Memo1.Handle, EM_LINESCROLL, , ln - );
end;

http://www.3aj.cn/delphi/article/1/279.html

使用

procedure TForm1.Button1Click(Sender: TObject);
begin
SelectLine(Memo1,);
ScrollToLine(Memo1,);
  //将水平的滚动条滚到最左边
SendMessage(Memo1.Handle, WM_HSCROLL, SB_LEFT, 0);
end;
05-04 02:21