procedure CaretPos(H: THandle; var L, C: Word);
begin
L := SendMessage(H, EM_LINEFROMCHAR, -1, 0);
C := LoWord(SendMessage(H, EM_GETSEL, 0, 0)) -
SendMessage(H, EM_LINEINDEX, -1, 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
LineNum, ColNum: Word;
begin
CaretPos(Memo1.Handle, LineNum, ColNum);
Edit1.Text := IntToStr(LineNum) + ' ' + IntToStr(ColNum);
end;
|