PDA

Click to See Complete Forum and Search --> : How to get cursor position in a RichTextControl ?


tdemoy
Jan 10th, 2001, 03:20 AM
I would like to know how can I get the cursor position in a RichTextControl using SendMessage API.

In fact, I want to get the column position of the cursor in the current line.

Many thanks,
Thierry

Jan 10th, 2001, 02:36 PM
You can use the GetLineFromChar method.

iLine = RichTextBox1.GetLineFromChar(RichTextBox1.SelStart) + 1

tdemoy
Jan 12th, 2001, 04:33 AM
I know how to get the current line.

What I would like to know is the number of characters from the begin of the current line !...

Example :


This is
my text

If the cursor is between the 't' and 'e' letters of 'text' word, I would like to get the position '5'.

Many Thanks,
Thierry

Jan 12th, 2001, 06:12 AM
Try this:

MsgBox Len(Left(Text1.Text, Text1.SelStart))

tdemoy
Jan 12th, 2001, 07:17 AM
This give you the position from the beginning of the text.
If my current line is 2, I want to get the position from the beginning of line # 2.

Thanks,
Thierry