Solved

get a cursor position in a Tmemo componant

Posted on 1998-04-22
2
225 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

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
Delphi cmd execution 6 56
Working this component WebCopy with proxy, help 3 76
how to update exe applicatio from internet ? 6 69
Convert MS Word document to a PDF file 9 65
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

22 Experts available now in Live!

Get 1:1 Help Now