Solved

How determine cursor position in TMemo component?

Posted on 1997-09-30
1
445 Views
Last Modified: 2010-05-18
Hi!

This question seems so darn easy, but I haven't been able to figure it out yet.
Question: How do I determine the row and column-position of the cursor in an active TMemo component? The only thing I've found is SELSTART, which tells me how many characters into the document the cursor is positioned. But what about row and column??
   I've solved the problem myself by counting how many #13-characters there is from the start of the memos text until the SelStart-value, but when the cursor reaches line 15 or so it begins to slow down program execution. (I wrote it in Pascal... haven't been assemling much lately). Maybe the same routine in inline-assembler would be acceptably fast. The routine has to be able to manage memos up to 500 rows long without putting suryp in the system, though.

Thanks!

//Daniel, Sweden
0
Comment
Question by:Dippen
1 Comment
 
LVL 4

Accepted Solution

by:
erajoj earned 100 total points
ID: 1346635
Hej Daniel!
It's not hard to accomplish if you are acquainted with
some of the messages that the TEdit responds to:

  with Memo1 do begin
    Row := SendMessage(Handle, EM_LINEFROMCHAR, -1, 0);
    Col := SelStart-SendMessage(Handle, EM_LINEINDEX, -1, 0);
  end;

/// John, also Sweden

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

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…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

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

28 Experts available now in Live!

Get 1:1 Help Now