Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Positioning TMemo cursor

135 views
Skip to first unread message

Graham Falkenberg

unread,
Sep 7, 1998, 3:00:00 AM9/7/98
to
I'm sure I've seen something like this somewhere, but, now that I need it,  I can't find it anywhere.   :-(

I put a string value into a TMemo and give the control focus. The cursor is positioned at the end of the TMemo.
Now I want to position the cursor at the start of the TMemo.

Does anybody know how I can do this?

Cheers,
Graham
 

CEHJohnson

unread,
Sep 7, 1998, 3:00:00 AM9/7/98
to
Graham,

This seems to work:

Memo1.SelStart := 0;
Memo1.SetFocus;

Charles Johnson

Gintaras Pikelis

unread,
Sep 9, 1998, 3:00:00 AM9/9/98
to
Our ColorMemo ( freeware) can do this.
It's at http://www.balticsolutions.com

Gintaras Pikelis
Baltic Solutions


AlanGLLoyd

unread,
Sep 13, 1998, 3:00:00 AM9/13/98
to
In article <35F31EFC...@senet.com.au>, Graham Falkenberg
<f...@senet.com.au> writes:

Some notes I did a little while ago on TMemo scrolling :-

If you just add lines to the TMemo (without BeginUpdate / EndUpdate), the
viewport scrolls to the last line added. However if you use BeginUpdate / add
lines / EndUpdate, then the viewport does not scroll.
If you want to position the viewport, you can then use the windows messages in
a Perform method to move the viewport. Some of the messages (with their
parameters) available are :-
(EM_Scroll, nScroll, 0) scrolls an amount defined by the second parameter
constant, the third parameter must be zero.
where nScroll is one of the constants SB_LINEDOWN, SB_LINEUP, SB_PAGEDOWN, or
SB_PAGEUP. The move is limited to those available, ie it does not scroll so
that the first or the last line is out of the viewport.

(EM_LineScroll, cxScroll, cyScroll)
where cxScroll and cyScroll are integers (+ve or -ve) to scroll characters
(cxScroll) or lines (cyScroll). The line move is limited to those available.

(EM_ScrollCaret, 0, 0) moves the viewport so that the caret is in the viewport.
where the second and third parameters must be zero.

Memo1.Perform(EM_SetSel, 0, 0); {move caret to top}
Memo1.Perform(EM_LineScroll, 0, Memo1.Lines.Count * -1); {move to top}
{or Memo1.Perform(EM_ScrollCaret, 0, 0); scroll caret into view}
Memo1.SetFocus;

Memo1.Perform(EM_SetSel, Memo1.GetTextLen, Memo1.GetTextLen); {move caret to
bottom}
Memo1.Perform(EM_LineScroll, 0, Memo1.Lines.Count); {move to bottom}
{or Memo1.Perform(EM_ScrollCaret, 0, 0); scroll caret into view}
Memo1.SetFocus;


Alan Lloyd
alang...@aol.com

0 new messages