你可以調用WindowsAPI中的EM―LINEFROM??CHAR和EM―LINEINDEX函數來確定MEM
O控件中的當前行和列,具體調用的過程見下面的過程。
var
LineNum:longint;
CharsBeforeLine:longint;
begin
LineNumΚSendMessage(Memo1.Handle,EM―LINEFROMCHAR,Memo1.SelSta
rt,0);
CharsBeforeLine:=SendMessage(Memo1.Handle,EM―LINEINDEX,LineNum
,0);
Label1.Caption:=′Line′+IntToStr(LineNum+1)
Label2.Caption:=′Position′+IntToStr((Memo1.SelStart-CharsBe
foreLine)+1);
end;