DelphiFAQ Home Search:

Have a TMemo/ TRichEdit scroll to the cursor position

 

comments9 comments. Current rating: 5 stars (4 votes). Leave comments and/ or rate it.

After placing the cursor at the desired position using the SelStart property,
you should use the EM_SCROLLCARET message to scroll the caret into view,
as shown in the piece of code below.

(To set the SelStart property to a x/y coordinate, also read this tip:
Access the current row/column of a TMemo.)

// scroll caret into view,
// the wParam, lParam parameters are ignored
SendMessage(Memo1.handle, EM_SCROLLCARET,0,0);

Comments:

2005-11-09, 05:03:05
daveb@cartoworld.com from South Africa  
rating
THanks !!!! That's just what i needed
2006-01-08, 20:07:37
p@ttersonm@rk(at)optusnet*com*au from Australia  
That was what I needed to! I used these lines to scroll to bottom of a log file:
RichEdit1.SelStart := MaxInt;
SendMessage(RichEdit1.handle, EM_SCROLLCARET,0,0);
2006-02-20, 04:21:52
anonymous from United Kingdom  
rating
very usefull - thanks
2006-03-31, 07:17:21
anonymous from Italy  
Many Thanks
2006-08-10, 08:48:27
anonymous from United Kingdom  
rating
I needed that! Thank you!
2006-10-09, 00:18:26
anonymous from Hungary  
THX man! You save my life
2006-12-14, 08:25:48
anonymous from United Kingdom  
nice
2007-06-11, 02:44:10
anonymous from Netherlands  
The EM_SCROLLCARET on Win2000+ doesn't work with the window minimized. Is there a way to solve this?
2008-10-19, 03:56:08
anonymous from Japan  
rating
Thank you - it was short, clear and solved the problem.

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Los Angeles, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.