Here is the code from Peter Below's snippets:

*******   position of caret in memo in row/col format:

Row := Memo1.PerForm(EM_LINEFROMCHAR,Memo1.SelStart,0);
Col := Memo1.SelStart-Memo1.Perform(EM_LINEINDEX,Row,0);

*******   position of caret in richedit control in row/col format:

Row := richedit1.PerForm(EM_EXLINEFROMCHAR,0, richedit1.SelStart);
Col := richedit1.SelStart - richedit1.Perform(EM_LINEINDEX,Row,0);



--- Robert Meek <[EMAIL PROTECTED]> wrote:

>       When using a TRichedit I've also used the following code to get the
> Line and column so they can be displayed in the StatusBar.  I'd like to do
> the same for a TMemo, but EM_EXLINEFROMCHAR requires Richedit in the uses
> clause and it's seems like overkill to have to include it just for this one
> message.  Is there a comparable way of handling this for a TMemo?
> 
> procedure TEditFrA.UpdateCursorPos(Sender: TObject);
> var
>   CharPos: TPoint;
> begin
>   CharPos.Y := SendMessage(FrMemo.Handle, EM_EXLINEFROMCHAR, 0,
>     FrMemo.SelStart);
>   CharPos.X := (FrMemo.SelStart -
>     SendMessage(FrMemo.Handle, EM_LINEINDEX, CharPos.Y, 0));
>   Inc(CharPos.Y);
>   Inc(CharPos.X);
>   Editor.LineColStatPane.Caption := InttoStr(CharPos.Y) + '/' +
> InttoStr(CharPos.X);
> end;
> 
> from Robert Meek dba Tangentals Design  CCopyright 2006
> Proud to be a moderator of "The Delphi Lists" at elists.org
> 
> "When I examine myself and my methods of thought, I come to the conclusion
> that the gift of Fantasy has meant more to me then my talent for absorbing
> positive knowledge!"
>                                                     Albert Einstein
> 
> 
> 
> _______________________________________________
> Delphi mailing list -> Delphi@elists.org
> http://www.elists.org/mailman/listinfo/delphi
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://www.elists.org/mailman/listinfo/delphi

Reply via email to