Scalabium Software

SMExport/SMImport suites
Knowledge for your independence'.
Home Delphi and C++Builder tips


#23: How can I get a line/column number that a memo/richtext cursor is on?

If you want to retrieve the line and/or column number you must send a messages to control and retrieve the result:

For TRichEdit you must send a EM_EXLINEFROMCHAR and EM_LINEINDEX messages.
For TMemo you must send a EM_LINEFROMCHAR and EM_LINEINDEX messages.

The WParam contains the character number that you wish the line number for, or -1 for the current line (where the caret is located or the beginning of a text selection).

View examples:
- for TMemo
LineNumber := SendMessage(Memo1.Handle, EM_LINEFROMCHAR, -1, 0);

- for TRichEdit
LineNumber  := SendMessage(RichEdit1.Handle, EM_EXLINEFROMCHAR, 0, RichEdit1.SelStart);
ColNumber := (RichEdit1.SelStart - SendMessage(RichEdit1.Handle, EM_LINEINDEX, LineNumber, 0));

PS: not forget that starting values is 0.


Published: September 23, 1999

See also
 
Viewer for MS Outlook Messages
SMDBGrid
ABA Picture Convert
Paradox Viewer
Metafile Convert
Mail parser (ActiveX)
Clarion to Text converter
DBLoad
SMMsg suite
ExcelFile Viewer
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2021, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMReport Autogenerated