TMemo cursor issue

Posted on 2004-10-28
Last Modified: 2010-04-05
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.
Question by:__alex
    LVL 2

    Author Comment

    Actual workaround:

    SelLength := 1;
    SelLength := 0;
    LVL 27

    Accepted Solution

    take a look to the em_scrollcaret api

    should be like


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

    just from head

    meikl ;-)
    LVL 17

    Assisted Solution

    Another way:

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

    Regards, Geo
    LVL 2

    Author Comment

    A simple call to SelLength does it? Weird...
    LVL 27

    Expert Comment

    >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 ;-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    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…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 ( But the ability to create custom scanning profiles al…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    877 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

    14 Experts available now in Live!

    Get 1:1 Help Now