Главная страница | назад





Article #17582: Getting the current line number of a TMemo?

 Question and Answer Database

FAQ2582D.txt   Getting the current line number of a TMemo?
Category   :VCL
Platform    :All
Product    :All 32 bit  

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;


7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99