TMemo cursor issue

Example:
My memo shows line 0 to 9 and its count is 30 (-> scrollbars show up). I set my cursor to line 15 via SelStart. How can I make my memo show the cursor, i.e. scroll to line 15.
LVL 2
__alexAsked:
Who is Participating?
 
kretzschmarConnect With a Mentor Commented:
take a look to the em_scrollcaret api

should be like

memo1.perform(em_scrollcaret,0,0);

maybe you must include the unit richedit into the uses-clause (not sure)

just from head

meikl ;-)
0
 
__alexAuthor Commented:
Actual workaround:

SelLength := 1;
SelLength := 0;
0
 
geobulConnect With a Mentor Commented:
Another way:

procedure MemoSetCursor(Memo: TMemo; CharIndex: integer);
begin
  Memo.SelStart := CharIndex;
  Memo.SelLength := 0;
end;

Regards, Geo
0
 
__alexAuthor Commented:
A simple call to SelLength does it? Weird...
0
 
kretzschmarCommented:
>A simple call to SelLength does it? Weird...
not really weird

internal is called then th em_setsel message

part from the docu about em_setsel
------------------------
In previous versions of Windows, the wParam parameter is a flag that is set to FALSE to scroll the caret into view or set to TRUE to omit the scrolling. A Win32-based application should use the EM_SCROLLCARET message to scroll the caret into view.
------------------------

guess it works because of this

meikl ;-)
0
All Courses

From novice to tech pro — start learning today.