Solved

get a cursor position in a Tmemo componant

Posted on 1998-04-22
2
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tvirtualstringtree freeze when load too manny images 10 94
Multi-layered image in FireMonkey 9 93
enhance the following code 3 54
Automatic field translation delphi 10.2 6 46
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 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