Solved

get a cursor position in a Tmemo componant

Posted on 1998-04-22
2
223 Views
Last Modified: 2010-08-05
I'm using Delphi2 and I would like to know:
How I can get the text cursor position in a memo componant?
...how to get the row and the position in a line of the cursor.
Exemple:
     a
my "a" is in the (relative) position of 6:6.
0
Comment
Question by:elbaid
2 Comments
 
LVL 5

Accepted Solution

by:
inter earned 50 total points
ID: 1336110
Try the following on OnChange event of memo:

procedure TtForm1.Memo1Change(Sender: TObject);
var ro, co: Integer;
begin
  ro := Memo1.Perform(EM_LINEFROMCHAR, Editor.SelStart, 0); //this is the row
  co := Memo1.SelStart - Editor.Perform(EM_LINEINDEX, ro, 0); // this is the col
  Form1.Caption :=  Format('Row: %d, Col %d', [ro + 1,co + 1]);//row col is 0 based
end;

Regards,
Igor

0
 

Author Comment

by:elbaid
ID: 1336111
Thanks!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 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

11 Experts available now in Live!

Get 1:1 Help Now