unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,shellapi;
type
TForm1 = class(TForm)
Label1: TLabel;
Memo1: TMemo;
Label2: TLabel;
procedure Memo1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var
LineNum:longint;
CharsBeforeLine:longint;
{$R *.DFM}
procedure TForm1.Memo1Change(Sender: TObject);
begin
LineNum:=SendMessage(Memo1.Handle,EM_LINEFROMCHAR,Memo1.SelStart,0);
CharsBeforeLine:=SendMessage(Memo1.Handle,EM_LINEINDEX,LineNum,0);
Label1.Caption:='Line'+IntToStr(LineNum+1);
Label2.Caption:='Position' +IntToStr((Memo1.SelStart-CharsBeforeLine)+1);
end;
end.
自己找到资料了