Solved

TMemo cursor issue

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

    Author Comment

    by:__alex
    Actual workaround:

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

    Accepted Solution

    by:
    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
     
    LVL 17

    Assisted Solution

    by:geobul
    Another way:

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

    Regards, Geo
    0
     
    LVL 2

    Author Comment

    by:__alex
    A simple call to SelLength does it? Weird...
    0
     
    LVL 27

    Expert Comment

    by:kretzschmar
    >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

    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 (http://www.experts-exchange.com/articles/17490/). 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