1. Home
  2. Computing & Technology
  3. Delphi Programming

Get the line number from a RichEdit

By Zarko Gajic, About.com

Yes, this function is missing from TRichEdit. You can get the line number from cursor by using a windows message (on a RichEdit named REdit):

REdit.Perform(EM_LINEFROMCHAR,REdit.SelStart,0) ;

this will return the line number. There is also a windows message (EM_CHARFROMPOS) that will return the character position from the screen cursor coordinates. Look in the windows help file for more info. Beware that these functions are pretty slow, and should not be used inside of loop that get called a lot.

Delphi tips navigator:
» Enable/Disable Desktop icons
« TColor to HTML color

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2000 Delphi Tips
  7. Get the line number from a RichEdit

©2009 About.com, a part of The New York Times Company.

All rights reserved.