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
Solved

get a cursor position in a Tmemo componant

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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
Convert Jpg /PNG To GIF 5 151
How to renew a Delphi rad-studio licence? 5 69
Controlled Assessment GCSE - desperate help needed 4 102
control image tags in a string ? 12 142
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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