先在窗口中布置一个RichEdit或者memo(命名为editor),以及一个button。在button的onclick事件中写入下列代码。
var
CurrentLine:Integer;
begin
CurrentLine:=Editor.Perform(em_LineFromChar,SFFFF,0);
ApplicationMessageBox(PChar(′当前行号是′+IntToStr(CurrentLine)),′消息′,mb_ iconinformation);
end;
需要注意的是,第一行的行号为零。
请看帮助