Get cursor Y position in Rich Edit

Posted on 1998-10-18
Last Modified: 2006-11-17
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?

Question by:genanja
  • 2

Accepted Solution

JimBob091197 earned 200 total points
ID: 1343287

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);


Author Comment

ID: 1343288
Jim you are wonderfull. It's working perfectly
Thank you very very much.....



Expert Comment

ID: 1343289
;-)  Glad to help.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
automatically logging in via bde delphi 3 68
calling procedure inside activexForm from secondform 1 231
Intraweb download file link ? 1 107
Base1 Encode/Decode 3 67
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now