通过调用API确定MEMO控件中的当前行和列

你可以调用WINDOWSAPI中的EM—LINEFROM睠HAR和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;