Solved

How determine cursor position in TMemo component?

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

17 Experts available now in Live!

Get 1:1 Help Now