@jamie,
Thank you for your advice and code. I have given some thought to this issue, and found out that the thing to notice is that Memo.Text <> Memo.Lines.Text. So your codes try to get the position of cursor within Memo.Text, and extract the whole string from it.
As I do not want to use SendMessage, etc. (just because I do not have enough knowledge on them), I rewrote the procedure as follows. The SelStart seems to return the position of Cursor if no text is selected.
The point is finding out which line the "SelStart" is located at within Memo.Text.
procedure TForm1.Button12Click(Sender: TObject);
var
i, Index, N : Integer;
MemoContent : TStringList;
begin
Index := memo1.SelStart;
if Index > Length(memo1.Text) then Exit;
N := 0;
for i := 0 to index do if memo1.Text[i] = #13 then N += 1;
MemoContent := TStringList.Create;
try
MemoContent.Text := Memo1.Lines.Text;
Showmessage(MemoContent[N]);
finally
MemoContent.Free;
end;
end;
This works fine as long as I use single byte characters. Now I'd like to use Korean characters. It looks like..
가나다
I'm not sure how this will be seen on your Windows (or Linix). This is three-character string so SelStart positions would be 0, 1, or 2.
But function Length('가나다') returns 9.
Is there any way that I can find the positions like,
for position := 0 to maxposition (memo1.text) do
if memo1.text[position] = #13 then N+=1;
Hope that you understand what I mean.
BTW, what is the consistent character to line break? #10 or #13?