Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

get a cursor position in a Tmemo componant

Posted on 1998-04-22
2
Medium Priority
?
234 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 200 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

927 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