Get cursor Y position in Rich Edit

How do i get the line where the cursor is in a Rich Edit Control. Not the cursor caracter position with Selstart but
The LINE position.
Anyone knows?

THX.
Avataris
genanjaAsked:
Who is Participating?
 
JimBob091197Connect With a Mentor Commented:
Hi

You use the EM_LINEFROMCHAR message.  For example, if you have a TRichEdit called rchTest, you could do the following:
  LineNum := rchTest.Perform(EM_LINEFROMCHAR, -1, 0);
(0 = 1st line, 1 = 2nd line, etc.)

For any character position, the following will return the line number:
  LineNum := rchTest.Perform(EM_LINEFROMCHAR, CharIndex, 0);

Similarly, the following will return the character index (like SelStart) for the 1st character on a line:
  CharIx := rchTest.Perform(EM_LINEINDEX, LineNum, 0);

Cheers,
JB
0
 
genanjaAuthor Commented:
Jim you are wonderfull. It's working perfectly
Thank you very very much.....

Avataris

0
 
JimBob091197Commented:
;-)  Glad to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.