2017年9月7日 星期四

RichEdit 操作

//取總行數
Count := RichEdit1.Perform(EM_GETLINECOUNT, 0, 0);

//取行列數
iCurY := SendMessage(RichEdit1.Handle, EM_LINEFROMCHAR, RichEdit1.SelStart, 0);
iCurX := RichEdit1.SelStart - SendMessage(RichEdit1.Handle, EM_LINEINDEX, iCurY, 0);

//取該行的字串長度
i := RichEdit1.Perform(EM_LINELENGTH, RichEdit1.SelStart, 0);

//選取指定行
procedure TForm1.pr_SelectRow(ARow:Integer);
var iLen, iY:Integer;
begin
  iLen := RichEdit1.Perform(EM_LINELENGTH, RichEdit1.SelStart, 0);
  RichEdit1.SelStart := RichEdit1.Perform(EM_LINEINDEX, ARow, 0);
  RichEdit1.SelLength := iLen;
end;

沒有留言:

張貼留言