Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

the position of the cursor in TRichEdit

Posted on 1999-07-13
5
Medium Priority
?
282 Views
Last Modified: 2010-08-05
How can we get the position of the cursor in TRichEdit?
0
Comment
Question by:mathematics
[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
  • 3
5 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1388052
hi mathematics,

what does you mean?
the coordinates?
the Line?
the charindex?

which position?

meikl
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 200 total points
ID: 1388053
hi mathematics,

this will display the current cursorpos in a richedit display in a statusbar in the context Line:Char

procedure TForm1.RichEdit1SelectionChange(Sender: TObject);
begin
  Statusbar1.SimpleText := InttoStr(RichEdit1.Perform(EM_LINEFROMCHAR,RichEdit1.selstart,0)+1)+':'+
                           IntToStr(richedit1.selstart-richedit1.Perform(EM_LINEINDEX,-1,0)+1);
end;

meikl
0
 
LVL 2

Expert Comment

by:kotik
ID: 1388054
You can get the cursor position using CaretPos:

RichEdit1.CaretPos.X  // zero based char number in the line
RichEdit1.CaretPos.Y  // zero based line number

To get the absolute caret position use SelStart property
CharIndex := RichEdit1.SelStart;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1388055
hi kotik,

must be a d4 feature, i've d3 and there is no caretpos!

well, mathematics, if you use d4, then u can use kotiks suggestion, because it seems to me easier to implement. in this case reject my answer.

meikl
0
 

Author Comment

by:mathematics
ID: 1388056
meikl,Thanks. Maybe RichEdit1.CaretPos.X is the pixels (X,Y).
I will try.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

670 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