Set Memo Cursor

Posted by Gregory on July 31, 2007

In Reply to Cursor help. posted by Chris Nevin on July 29, 2007

: Basically I have written something that takes a block of text from an invisible memo and copies it letter for letter into a visible memo, to give the illusion of something being typed out. The problem is that I am trying to make it look like a dos style box, and therefore want a cursor to be flashing at the end of the sentence as it is typed.
: The way I have achieved the typing affect so far has involved copying an individual letter to a seperate memo so that I could then use memo2.text:=memo2.text+
: so that it added the letter on the end as using pastefromclipboard seems to completely replace the text even if you have set the selstart position to the end of the block of text, which is annoying.
: The problem is, that this way of doing things seems to leave the cursor at the beggining of the sentence until it is finished when using memo2.selstart:=(memo2.gettextlength) puts it at the end.

Setting SelStart of TMemo puts memo-cursor just after indicated character, examples:

Memo.SelStart := 10;               // puts cursor after tenth character
Memo.SelStart := Memo2.GetTextLen; // puts cursor after last character

If indicated character character is not visible, you won't see cursor! To show cursor position, set Memo.SelLength.

Your code becomes:

Memo2.Text := Memo2.Text + A_Char_From_Memo1;
Memo2.Selstart := Memo2.GetTextLen;
Memo2.SelLength := 0; 

Good luck!

Related articles


Follow Ups