Solved

How determine cursor position in TMemo component?

Posted on 1997-09-30
1
451 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
[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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb download file link ? 1 167
Making delphi communicate with a c# service 16 123
Dev Express grid collapse 2 47
Typecasting TBytes to Integer in Delphi XE8 2 36
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 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…

749 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