- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


Frequently Asked Questions

Getting the current line number of a TMemo?

Question:

How can I determine the current line number of a TMemo?

Answer:

You can use the Windows EM_LINEFROMCHAR message to get 

the current (zero based) line number (position of the 

caret) of any edit control.



Example:



procedure TForm1.Button1Click(Sender: TObject);

var

  LineNumber : integer;

begin

  LineNumber := SendMessage(Memo1.Handle,

                            EM_LINEFROMCHAR,

                            word(-1),

                            0);

  ShowMessage(IntToStr(LineNumber));

end;




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile